Class: FlowChat::Whatsapp::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_chat/whatsapp/renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, choices: nil, media: nil) ⇒ Renderer

Returns a new instance of Renderer.



6
7
8
9
10
# File 'lib/flow_chat/whatsapp/renderer.rb', line 6

def initialize(message, choices: nil, media: nil)
  @message = message
  @choices = choices
  @media = media
end

Instance Attribute Details

#choicesObject (readonly)

Returns the value of attribute choices.



4
5
6
# File 'lib/flow_chat/whatsapp/renderer.rb', line 4

def choices
  @choices
end

#mediaObject (readonly)

Returns the value of attribute media.



4
5
6
# File 'lib/flow_chat/whatsapp/renderer.rb', line 4

def media
  @media
end

#messageObject (readonly)

Returns the value of attribute message.



4
5
6
# File 'lib/flow_chat/whatsapp/renderer.rb', line 4

def message
  @message
end

Instance Method Details

#renderObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/flow_chat/whatsapp/renderer.rb', line 12

def render
  if media && choices
    build_selection_message_with_media
  elsif media
    build_media_message
  elsif choices
    build_selection_message
  else
    build_text_message
  end
end