Class: FamilyappSdk::Components::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/familyapp_sdk/components/element.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title:, subtitle: nil, image: nil, url: nil, payload: nil, buttons: nil) ⇒ Element

Returns a new instance of Element.



6
7
8
9
10
11
12
13
# File 'lib/familyapp_sdk/components/element.rb', line 6

def initialize(title:, subtitle: nil, image: nil, url: nil, payload: nil, buttons: nil)
  @title = title
  @subtitle = subtitle
  @image = image
  @url = url
  @payload = payload
  @buttons_attributes = build_attributes(buttons)
end

Instance Attribute Details

#buttonsObject

Returns the value of attribute buttons.



4
5
6
# File 'lib/familyapp_sdk/components/element.rb', line 4

def buttons
  @buttons
end

#imageObject

Returns the value of attribute image.



4
5
6
# File 'lib/familyapp_sdk/components/element.rb', line 4

def image
  @image
end

#payloadObject

Returns the value of attribute payload.



4
5
6
# File 'lib/familyapp_sdk/components/element.rb', line 4

def payload
  @payload
end

#subtitleObject

Returns the value of attribute subtitle.



4
5
6
# File 'lib/familyapp_sdk/components/element.rb', line 4

def subtitle
  @subtitle
end

#titleObject

Returns the value of attribute title.



4
5
6
# File 'lib/familyapp_sdk/components/element.rb', line 4

def title
  @title
end

#urlObject

Returns the value of attribute url.



4
5
6
# File 'lib/familyapp_sdk/components/element.rb', line 4

def url
  @url
end

Instance Method Details

#buildObject



15
16
17
# File 'lib/familyapp_sdk/components/element.rb', line 15

def build
  instance_values.delete_if { |_attribute, value| value.nil? }
end

#build_attributes(attributes) ⇒ Object



19
20
21
# File 'lib/familyapp_sdk/components/element.rb', line 19

def build_attributes(attributes)
  attributes.map(&:build) if attributes.present?
end