Class: Line::Bot::V2::MessagingApi::FlexBox

Inherits:
FlexComponent show all
Defined in:
lib/line/bot/v2/messaging_api/model/flex_box.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(layout:, flex: nil, contents:, spacing: nil, margin: nil, position: nil, offset_top: nil, offset_bottom: nil, offset_start: nil, offset_end: nil, background_color: nil, border_color: nil, border_width: nil, corner_radius: nil, width: nil, max_width: nil, height: nil, max_height: nil, padding_all: nil, padding_top: nil, padding_bottom: nil, padding_start: nil, padding_end: nil, action: nil, justify_content: nil, align_items: nil, background: nil, **dynamic_attributes) ⇒ FlexBox

Returns a new instance of FlexBox.

Parameters:

  • layout (String)

    (‘horizontal’|‘vertical’|‘baseline’)

  • flex (Integer, nil) (defaults to: nil)
  • contents (Array[FlexComponent, Hash[Symbol, untyped]])
  • spacing (String, nil) (defaults to: nil)
  • margin (String, nil) (defaults to: nil)
  • position (String, nil) (defaults to: nil)

    (‘relative’|‘absolute’)

  • offset_top (String, nil) (defaults to: nil)
  • offset_bottom (String, nil) (defaults to: nil)
  • offset_start (String, nil) (defaults to: nil)
  • offset_end (String, nil) (defaults to: nil)
  • background_color (String, nil) (defaults to: nil)
  • border_color (String, nil) (defaults to: nil)
  • border_width (String, nil) (defaults to: nil)
  • corner_radius (String, nil) (defaults to: nil)
  • width (String, nil) (defaults to: nil)
  • max_width (String, nil) (defaults to: nil)
  • height (String, nil) (defaults to: nil)
  • max_height (String, nil) (defaults to: nil)
  • padding_all (String, nil) (defaults to: nil)
  • padding_top (String, nil) (defaults to: nil)
  • padding_bottom (String, nil) (defaults to: nil)
  • padding_start (String, nil) (defaults to: nil)
  • padding_end (String, nil) (defaults to: nil)
  • action (Action, Hash[Symbol, untyped], nil) (defaults to: nil)
  • justify_content (String, nil) (defaults to: nil)

    (‘center’|‘flex-start’|‘flex-end’|‘space-between’|‘space-around’|‘space-evenly’)

  • align_items (String, nil) (defaults to: nil)

    (‘center’|‘flex-start’|‘flex-end’)

  • background (FlexBoxBackground, Hash[Symbol, untyped], nil) (defaults to: nil)


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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 129

def initialize(
  layout:,
  flex: nil,
  contents:,
  spacing: nil,
  margin: nil,
  position: nil,
  offset_top: nil,
  offset_bottom: nil,
  offset_start: nil,
  offset_end: nil,
  background_color: nil,
  border_color: nil,
  border_width: nil,
  corner_radius: nil,
  width: nil,
  max_width: nil,
  height: nil,
  max_height: nil,
  padding_all: nil,
  padding_top: nil,
  padding_bottom: nil,
  padding_start: nil,
  padding_end: nil,
  action: nil,
  justify_content: nil,
  align_items: nil,
  background: nil,
  **dynamic_attributes
)
  @type = "box"
  
  @layout = layout
  @flex = flex
  @contents = contents.map do |item|
    if item.is_a?(Hash)
      Line::Bot::V2::MessagingApi::FlexComponent.create(**item) # steep:ignore InsufficientKeywordArguments
    else
      item
    end
  end
  @spacing = spacing
  @margin = margin
  @position = position
  @offset_top = offset_top
  @offset_bottom = offset_bottom
  @offset_start = offset_start
  @offset_end = offset_end
  @background_color = background_color
  @border_color = border_color
  @border_width = border_width
  @corner_radius = corner_radius
  @width = width
  @max_width = max_width
  @height = height
  @max_height = max_height
  @padding_all = padding_all
  @padding_top = padding_top
  @padding_bottom = padding_bottom
  @padding_start = padding_start
  @padding_end = padding_end
  @action = action.is_a?(Line::Bot::V2::MessagingApi::Action) || action.nil? ? action : Line::Bot::V2::MessagingApi::Action.create(**action) # steep:ignore
  @justify_content = justify_content
  @align_items = align_items
  @background = background.is_a?(Line::Bot::V2::MessagingApi::FlexBoxBackground) || background.nil? ? background : Line::Bot::V2::MessagingApi::FlexBoxBackground.create(**background) # steep:ignore

  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

#actionAction?

Returns:



91
92
93
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 91

def action
  @action
end

#align_itemsString?

Returns (‘center’|‘flex-start’|‘flex-end’).

Returns:

  • (String, nil)

    (‘center’|‘flex-start’|‘flex-end’)



97
98
99
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 97

def align_items
  @align_items
end

#backgroundFlexBoxBackground?

Returns:



100
101
102
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 100

def background
  @background
end

#background_colorString?

Returns:

  • (String, nil)


52
53
54
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 52

def background_color
  @background_color
end

#border_colorString?

Returns:

  • (String, nil)


55
56
57
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 55

def border_color
  @border_color
end

#border_widthString?

Returns:

  • (String, nil)


58
59
60
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 58

def border_width
  @border_width
end

#contentsArray[FlexComponent]

Returns:



28
29
30
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 28

def contents
  @contents
end

#corner_radiusString?

Returns:

  • (String, nil)


61
62
63
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 61

def corner_radius
  @corner_radius
end

#flexInteger?

Returns:

  • (Integer, nil)


25
26
27
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 25

def flex
  @flex
end

#heightString?

Returns:

  • (String, nil)


70
71
72
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 70

def height
  @height
end

#justify_contentString?

Returns (‘center’|‘flex-start’|‘flex-end’|‘space-between’|‘space-around’|‘space-evenly’).

Returns:

  • (String, nil)

    (‘center’|‘flex-start’|‘flex-end’|‘space-between’|‘space-around’|‘space-evenly’)



94
95
96
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 94

def justify_content
  @justify_content
end

#layoutString

Returns (‘horizontal’|‘vertical’|‘baseline’).

Returns:

  • (String)

    (‘horizontal’|‘vertical’|‘baseline’)



22
23
24
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 22

def layout
  @layout
end

#marginString?

Returns:

  • (String, nil)


34
35
36
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 34

def margin
  @margin
end

#max_heightString?

Returns:

  • (String, nil)


73
74
75
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 73

def max_height
  @max_height
end

#max_widthString?

Returns:

  • (String, nil)


67
68
69
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 67

def max_width
  @max_width
end

#offset_bottomString?

Returns:

  • (String, nil)


43
44
45
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 43

def offset_bottom
  @offset_bottom
end

#offset_endString?

Returns:

  • (String, nil)


49
50
51
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 49

def offset_end
  @offset_end
end

#offset_startString?

Returns:

  • (String, nil)


46
47
48
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 46

def offset_start
  @offset_start
end

#offset_topString?

Returns:

  • (String, nil)


40
41
42
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 40

def offset_top
  @offset_top
end

#padding_allString?

Returns:

  • (String, nil)


76
77
78
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 76

def padding_all
  @padding_all
end

#padding_bottomString?

Returns:

  • (String, nil)


82
83
84
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 82

def padding_bottom
  @padding_bottom
end

#padding_endString?

Returns:

  • (String, nil)


88
89
90
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 88

def padding_end
  @padding_end
end

#padding_startString?

Returns:

  • (String, nil)


85
86
87
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 85

def padding_start
  @padding_start
end

#padding_topString?

Returns:

  • (String, nil)


79
80
81
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 79

def padding_top
  @padding_top
end

#positionString?

Returns (‘relative’|‘absolute’).

Returns:

  • (String, nil)

    (‘relative’|‘absolute’)



37
38
39
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 37

def position
  @position
end

#spacingString?

Returns:

  • (String, nil)


31
32
33
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 31

def spacing
  @spacing
end

#typeObject (readonly)

Returns the value of attribute type.



19
20
21
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 19

def type
  @type
end

#widthString?

Returns:

  • (String, nil)


64
65
66
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 64

def width
  @width
end

Class Method Details

.create(args) ⇒ Line::Bot::V2::MessagingApi::FlexBox

Create an instance of the class from a hash

Parameters:

  • args (Hash)

    Hash containing all the required attributes

Returns:



211
212
213
214
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 211

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.

Parameters:

  • other (Object)

    Object to compare

Returns:

  • (Boolean)

    true if the objects are equal, false otherwise



218
219
220
221
222
223
224
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 218

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

#hashInteger

Returns Hash code of the object.

Returns:

  • (Integer)

    Hash code of the object



227
228
229
# File 'lib/line/bot/v2/messaging_api/model/flex_box.rb', line 227

def hash
  [self.class, *instance_variables.map { |var| instance_variable_get(var) }].hash
end