Class: ChatSDK::Cards::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/chat_sdk/cards/renderer.rb

Instance Method Summary collapse

Instance Method Details

#render(node) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/chat_sdk/cards/renderer.rb', line 6

def render(node)
  case node.type
  when :card then render_card(node)
  when :text then node.attributes[:content]
  when :divider then "---"
  when :image then "![#{node.attributes[:alt]}](#{node.attributes[:url]})"
  when :fields then render_fields(node)
  when :field then "**#{node.attributes[:label]}**: #{node.attributes[:value]}"
  when :section then render_section(node)
  when :actions then render_actions(node)
  when :button then "[#{node.attributes[:text]}]"
  when :link_button then "[#{node.attributes[:text]}](#{node.attributes[:url]})"
  when :select then "_#{node.attributes[:placeholder] || "Select"}_"
  else ""
  end
end