Class: Line::Bot::V2::MessagingApi::FlexText
- Inherits:
-
FlexComponent
- Object
- FlexComponent
- Line::Bot::V2::MessagingApi::FlexText
- Defined in:
- lib/line/bot/v2/messaging_api/model/flex_text.rb
Instance Attribute Summary collapse
- #action ⇒ Action?
-
#adjust_mode ⇒ String?
(‘shrink-to-fit’).
-
#align ⇒ String?
(‘start’|‘end’|‘center’).
- #color ⇒ String?
- #contents ⇒ Array[FlexSpan]?
-
#decoration ⇒ String?
(‘none’|‘underline’|‘line-through’).
- #flex ⇒ Integer?
-
#gravity ⇒ String?
(‘top’|‘bottom’|‘center’).
- #line_spacing ⇒ String?
- #margin ⇒ String?
- #max_lines ⇒ Integer?
- #offset_bottom ⇒ String?
- #offset_end ⇒ String?
- #offset_start ⇒ String?
- #offset_top ⇒ String?
-
#position ⇒ String?
(‘relative’|‘absolute’).
- #scaling ⇒ Boolean?
- #size ⇒ String?
-
#style ⇒ String?
(‘normal’|‘italic’).
- #text ⇒ String?
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#weight ⇒ String?
(‘regular’|‘bold’).
- #wrap ⇒ Boolean?
Class Method Summary collapse
-
.create(args) ⇒ Line::Bot::V2::MessagingApi::FlexText
Create an instance of the class from a hash.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
True if the objects are equal, false otherwise.
-
#hash ⇒ Integer
Hash code of the object.
-
#initialize(flex: nil, text: nil, size: nil, align: nil, gravity: nil, color: nil, weight: nil, style: nil, decoration: nil, wrap: nil, line_spacing: nil, margin: nil, position: nil, offset_top: nil, offset_bottom: nil, offset_start: nil, offset_end: nil, action: nil, max_lines: nil, contents: nil, adjust_mode: nil, scaling: nil, **dynamic_attributes) ⇒ FlexText
constructor
A new instance of FlexText.
Constructor Details
#initialize(flex: nil, text: nil, size: nil, align: nil, gravity: nil, color: nil, weight: nil, style: nil, decoration: nil, wrap: nil, line_spacing: nil, margin: nil, position: nil, offset_top: nil, offset_bottom: nil, offset_start: nil, offset_end: nil, action: nil, max_lines: nil, contents: nil, adjust_mode: nil, scaling: nil, **dynamic_attributes) ⇒ FlexText
Returns a new instance of FlexText.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 109 def initialize( flex: nil, text: nil, size: nil, align: nil, gravity: nil, color: nil, weight: nil, style: nil, decoration: nil, wrap: nil, line_spacing: nil, margin: nil, position: nil, offset_top: nil, offset_bottom: nil, offset_start: nil, offset_end: nil, action: nil, max_lines: nil, contents: nil, adjust_mode: nil, scaling: nil, **dynamic_attributes ) @type = "text" @flex = flex @text = text @size = size @align = align @gravity = gravity @color = color @weight = weight @style = style @decoration = decoration @wrap = wrap @line_spacing = line_spacing @margin = margin @position = position @offset_top = offset_top @offset_bottom = offset_bottom @offset_start = offset_start @offset_end = offset_end @action = action.is_a?(Line::Bot::V2::MessagingApi::Action) || action.nil? ? action : Line::Bot::V2::MessagingApi::Action.create(**action) # steep:ignore @max_lines = max_lines @contents = contents&.map do |item| if item.is_a?(Hash) Line::Bot::V2::MessagingApi::FlexSpan.create(**item) # steep:ignore InsufficientKeywordArguments else item end end @adjust_mode = adjust_mode @scaling = scaling dynamic_attributes.each do |key, value| self.class.attr_accessor key if value.is_a?(Hash) struct_klass = Struct.new(*value.keys.map(&:to_sym)) struct_values = value.map { |_k, v| v.is_a?(Hash) ? Line::Bot::V2::Utils.hash_to_struct(v) : v } instance_variable_set("@#{key}", struct_klass.new(*struct_values)) else instance_variable_set("@#{key}", value) end end end |
Instance Attribute Details
#action ⇒ Action?
73 74 75 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 73 def action @action end |
#adjust_mode ⇒ String?
Returns (‘shrink-to-fit’).
82 83 84 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 82 def adjust_mode @adjust_mode end |
#align ⇒ String?
Returns (‘start’|‘end’|‘center’).
31 32 33 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 31 def align @align end |
#color ⇒ String?
37 38 39 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 37 def color @color end |
#contents ⇒ Array[FlexSpan]?
79 80 81 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 79 def contents @contents end |
#decoration ⇒ String?
Returns (‘none’|‘underline’|‘line-through’).
46 47 48 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 46 def decoration @decoration end |
#flex ⇒ Integer?
22 23 24 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 22 def flex @flex end |
#gravity ⇒ String?
Returns (‘top’|‘bottom’|‘center’).
34 35 36 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 34 def gravity @gravity end |
#line_spacing ⇒ String?
52 53 54 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 52 def line_spacing @line_spacing end |
#margin ⇒ String?
55 56 57 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 55 def margin @margin end |
#max_lines ⇒ Integer?
76 77 78 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 76 def max_lines @max_lines end |
#offset_bottom ⇒ String?
64 65 66 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 64 def offset_bottom @offset_bottom end |
#offset_end ⇒ String?
70 71 72 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 70 def offset_end @offset_end end |
#offset_start ⇒ String?
67 68 69 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 67 def offset_start @offset_start end |
#offset_top ⇒ String?
61 62 63 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 61 def offset_top @offset_top end |
#position ⇒ String?
Returns (‘relative’|‘absolute’).
58 59 60 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 58 def position @position end |
#scaling ⇒ Boolean?
85 86 87 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 85 def scaling @scaling end |
#size ⇒ String?
28 29 30 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 28 def size @size end |
#style ⇒ String?
Returns (‘normal’|‘italic’).
43 44 45 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 43 def style @style end |
#text ⇒ String?
25 26 27 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 25 def text @text end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
19 20 21 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 19 def type @type end |
#weight ⇒ String?
Returns (‘regular’|‘bold’).
40 41 42 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 40 def weight @weight end |
#wrap ⇒ Boolean?
49 50 51 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 49 def wrap @wrap end |
Class Method Details
.create(args) ⇒ Line::Bot::V2::MessagingApi::FlexText
Create an instance of the class from a hash
181 182 183 184 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 181 def self.create(args) # steep:ignore symbolized_args = Line::Bot::V2::Utils.deep_symbolize(args) return new(**symbolized_args) # steep:ignore end |
Instance Method Details
#==(other) ⇒ Boolean
Returns true if the objects are equal, false otherwise.
188 189 190 191 192 193 194 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 188 def ==(other) return false unless self.class == other.class instance_variables.all? do |var| instance_variable_get(var) == other.instance_variable_get(var) end end |
#hash ⇒ Integer
Returns Hash code of the object.
197 198 199 |
# File 'lib/line/bot/v2/messaging_api/model/flex_text.rb', line 197 def hash [self.class, *instance_variables.map { |var| instance_variable_get(var) }].hash end |