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

Returns a new instance of FlexIcon.

Parameters:

  • url (String)
  • size (String, nil) (defaults to: nil)
  • aspect_ratio (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)
  • scaling (Boolean, nil) (defaults to: nil)


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?

Returns:

  • (String, nil)


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

def aspect_ratio
  @aspect_ratio
end

#marginString?

Returns:

  • (String, nil)


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

def margin
  @margin
end

#offset_bottomString?

Returns:

  • (String, nil)


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

def offset_bottom
  @offset_bottom
end

#offset_endString?

Returns:

  • (String, nil)


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

def offset_end
  @offset_end
end

#offset_startString?

Returns:

  • (String, nil)


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

def offset_start
  @offset_start
end

#offset_topString?

Returns:

  • (String, nil)


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

def offset_top
  @offset_top
end

#positionString?

Returns (‘relative’|‘absolute’).

Returns:

  • (String, nil)

    (‘relative’|‘absolute’)



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

def position
  @position
end

#scalingBoolean?

Returns:

  • (Boolean, nil)


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

def scaling
  @scaling
end

#sizeString?

Returns:

  • (String, nil)


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

Returns:

  • (String)


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

Parameters:

  • args (Hash)

    Hash containing all the required attributes

Returns:



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

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



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

Returns Hash code of the object.

Returns:

  • (Integer)

    Hash code of the object



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