Class: Line::Bot::V2::MessagingApi::FlexButton
- Inherits:
-
FlexComponent
- Object
- FlexComponent
- Line::Bot::V2::MessagingApi::FlexButton
- Defined in:
- lib/line/bot/v2/messaging_api/model/flex_button.rb
Instance Attribute Summary collapse
- #action ⇒ Action
-
#adjust_mode ⇒ String?
(‘shrink-to-fit’).
- #color ⇒ String?
- #flex ⇒ Integer?
-
#gravity ⇒ String?
(‘top’|‘bottom’|‘center’).
-
#height ⇒ String?
(‘md’|‘sm’).
- #margin ⇒ String?
- #offset_bottom ⇒ String?
- #offset_end ⇒ String?
- #offset_start ⇒ String?
- #offset_top ⇒ String?
-
#position ⇒ String?
(‘relative’|‘absolute’).
- #scaling ⇒ Boolean?
-
#style ⇒ String?
(‘primary’|‘secondary’|‘link’).
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.create(args) ⇒ Line::Bot::V2::MessagingApi::FlexButton
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, color: nil, style: nil, action:, gravity: nil, margin: nil, position: nil, offset_top: nil, offset_bottom: nil, offset_start: nil, offset_end: nil, height: nil, adjust_mode: nil, scaling: nil, **dynamic_attributes) ⇒ FlexButton
constructor
A new instance of FlexButton.
Constructor Details
#initialize(flex: nil, color: nil, style: nil, action:, gravity: nil, margin: nil, position: nil, offset_top: nil, offset_bottom: nil, offset_start: nil, offset_end: nil, height: nil, adjust_mode: nil, scaling: nil, **dynamic_attributes) ⇒ FlexButton
Returns a new instance of FlexButton.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/line/bot/v2/messaging_api/model/flex_button.rb', line 77 def initialize( flex: nil, color: nil, style: nil, action:, gravity: nil, margin: nil, position: nil, offset_top: nil, offset_bottom: nil, offset_start: nil, offset_end: nil, height: nil, adjust_mode: nil, scaling: nil, **dynamic_attributes ) @type = "button" @flex = flex @color = color @style = style @action = action.is_a?(Line::Bot::V2::MessagingApi::Action) ? action : Line::Bot::V2::MessagingApi::Action.create(**action) # steep:ignore @gravity = gravity @margin = margin @position = position @offset_top = offset_top @offset_bottom = offset_bottom @offset_start = offset_start @offset_end = offset_end @height = height @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
31 32 33 |
# File 'lib/line/bot/v2/messaging_api/model/flex_button.rb', line 31 def action @action end |
#adjust_mode ⇒ String?
Returns (‘shrink-to-fit’).
58 59 60 |
# File 'lib/line/bot/v2/messaging_api/model/flex_button.rb', line 58 def adjust_mode @adjust_mode end |
#color ⇒ String?
25 26 27 |
# File 'lib/line/bot/v2/messaging_api/model/flex_button.rb', line 25 def color @color end |
#flex ⇒ Integer?
22 23 24 |
# File 'lib/line/bot/v2/messaging_api/model/flex_button.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_button.rb', line 34 def gravity @gravity end |
#height ⇒ String?
Returns (‘md’|‘sm’).
55 56 57 |
# File 'lib/line/bot/v2/messaging_api/model/flex_button.rb', line 55 def height @height end |
#margin ⇒ String?
37 38 39 |
# File 'lib/line/bot/v2/messaging_api/model/flex_button.rb', line 37 def margin @margin end |
#offset_bottom ⇒ String?
46 47 48 |
# File 'lib/line/bot/v2/messaging_api/model/flex_button.rb', line 46 def offset_bottom @offset_bottom end |
#offset_end ⇒ String?
52 53 54 |
# File 'lib/line/bot/v2/messaging_api/model/flex_button.rb', line 52 def offset_end @offset_end end |
#offset_start ⇒ String?
49 50 51 |
# File 'lib/line/bot/v2/messaging_api/model/flex_button.rb', line 49 def offset_start @offset_start end |
#offset_top ⇒ String?
43 44 45 |
# File 'lib/line/bot/v2/messaging_api/model/flex_button.rb', line 43 def offset_top @offset_top end |
#position ⇒ String?
Returns (‘relative’|‘absolute’).
40 41 42 |
# File 'lib/line/bot/v2/messaging_api/model/flex_button.rb', line 40 def position @position end |
#scaling ⇒ Boolean?
61 62 63 |
# File 'lib/line/bot/v2/messaging_api/model/flex_button.rb', line 61 def scaling @scaling end |
#style ⇒ String?
Returns (‘primary’|‘secondary’|‘link’).
28 29 30 |
# File 'lib/line/bot/v2/messaging_api/model/flex_button.rb', line 28 def style @style end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
19 20 21 |
# File 'lib/line/bot/v2/messaging_api/model/flex_button.rb', line 19 def type @type end |
Class Method Details
.create(args) ⇒ Line::Bot::V2::MessagingApi::FlexButton
Create an instance of the class from a hash
127 128 129 130 |
# File 'lib/line/bot/v2/messaging_api/model/flex_button.rb', line 127 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.
134 135 136 137 138 139 140 |
# File 'lib/line/bot/v2/messaging_api/model/flex_button.rb', line 134 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.
143 144 145 |
# File 'lib/line/bot/v2/messaging_api/model/flex_button.rb', line 143 def hash [self.class, *instance_variables.map { |var| instance_variable_get(var) }].hash end |