Class: Ralyxa::ResponseEntities::Card

Inherits:
Object
  • Object
show all
Defined in:
lib/ralyxa/response_entities/card.rb

Constant Summary collapse

'LinkAccount'.freeze
SIMPLE_CARD_TYPE =
'Simple'.freeze
STANDARD_CARD_TYPE =
'Standard'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Card

Returns a new instance of Card.



10
11
12
# File 'lib/ralyxa/response_entities/card.rb', line 10

def initialize(options)
  @options = options
end

Class Method Details

.as_hash(title, body, small_image_url = nil, large_image_url = small_image_url) ⇒ Object



14
15
16
# File 'lib/ralyxa/response_entities/card.rb', line 14

def self.as_hash(title, body, small_image_url = nil, large_image_url = small_image_url)
  new(title: title, body: body, small_image_url: small_image_url, large_image_url: large_image_url).to_h
end


18
19
20
# File 'lib/ralyxa/response_entities/card.rb', line 18

def self.
  new(link_account: true).to_h
end

Instance Method Details

#to_hObject



22
23
24
25
26
27
28
29
# File 'lib/ralyxa/response_entities/card.rb', line 22

def to_h
  {}.tap do |card|
    add_type(card)
    add_title(card) if @options[:title]
    add_body(card)  if @options[:body]
    add_image(card) if standard?
  end
end