Class: Line::Bot::V2::MessagingApi::FlexIcon

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

Overview

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:, size: nil, aspect_ratio: nil, margin: nil, position: nil, offset_top: nil, offset_bottom: nil, offset_start: nil, offset_end: nil, scaling: nil, **dynamic_attributes) ⇒ FlexIcon



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/line/bot/v2/messaging_api/model/flex_icon.rb', line 62

def initialize(
  url:,
  size: nil,
  aspect_ratio: nil,
  margin: nil,
  position: nil,
  offset_top: nil,
  offset_bottom: nil,
  offset_start: nil,
  offset_end: nil,
  scaling: nil,
  **dynamic_attributes
)
  @type = "icon"
  
  @url = url
  @size = size
  @aspect_ratio = aspect_ratio
  @margin = margin
  @position = position
  @offset_top = offset_top
  @offset_bottom = offset_bottom
  @offset_start = offset_start
  @offset_end = offset_end
  @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

#aspect_ratioString?



29
30
31
# File 'lib/line/bot/v2/messaging_api/model/flex_icon.rb', line 29

def aspect_ratio
  @aspect_ratio
end

#marginString?



32
33
34
# File 'lib/line/bot/v2/messaging_api/model/flex_icon.rb', line 32

def margin
  @margin
end

#offset_bottomString?



41
42
43
# File 'lib/line/bot/v2/messaging_api/model/flex_icon.rb', line 41

def offset_bottom
  @offset_bottom
end

#offset_endString?



47
48
49
# File 'lib/line/bot/v2/messaging_api/model/flex_icon.rb', line 47

def offset_end
  @offset_end
end

#offset_startString?



44
45
46
# File 'lib/line/bot/v2/messaging_api/model/flex_icon.rb', line 44

def offset_start
  @offset_start
end

#offset_topString?



38
39
40
# File 'lib/line/bot/v2/messaging_api/model/flex_icon.rb', line 38

def offset_top
  @offset_top
end

#positionString?



35
36
37
# File 'lib/line/bot/v2/messaging_api/model/flex_icon.rb', line 35

def position
  @position
end

#scalingBoolean?



50
51
52
# File 'lib/line/bot/v2/messaging_api/model/flex_icon.rb', line 50

def scaling
  @scaling
end

#sizeString?



26
27
28
# File 'lib/line/bot/v2/messaging_api/model/flex_icon.rb', line 26

def size
  @size
end

#typeObject (readonly)

Returns the value of attribute type.



20
21
22
# File 'lib/line/bot/v2/messaging_api/model/flex_icon.rb', line 20

def type
  @type
end

#urlString



23
24
25
# File 'lib/line/bot/v2/messaging_api/model/flex_icon.rb', line 23

def url
  @url
end

Class Method Details

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

Create an instance of the class from a hash



104
105
106
107
# File 'lib/line/bot/v2/messaging_api/model/flex_icon.rb', line 104

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



111
112
113
114
115
116
117
# File 'lib/line/bot/v2/messaging_api/model/flex_icon.rb', line 111

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



120
121
122
# File 'lib/line/bot/v2/messaging_api/model/flex_icon.rb', line 120

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