module Kamiflex::Core
Public Instance Methods
alt_text(text)
click to toggle source
# File lib/kamiflex/core.rb, line 78 def alt_text(text) @flex_attributes[:altText] = text end
baseline_box(resources = [nil], **params, &block)
click to toggle source
# File lib/kamiflex/core.rb, line 98 def baseline_box(resources = [nil], **params, &block) horizontal_box(resources, layout: "baseline", **params, &block) end
body(**params) { || ... }
click to toggle source
# File lib/kamiflex/core.rb, line 55 def body(**params) _attributes, contents = flex_scope{ yield } @flex_attributes[:body] = { type: "box", layout: "vertical", contents: contents }.merge(params) end
bubble(**params) { || ... }
click to toggle source
# File lib/kamiflex/core.rb, line 12 def bubble(**params) attributes, _contents = flex_scope{ yield } @flex_contents << { type: "bubble" }.merge(attributes.slice(:size, :direction, :header, :hero, :body, :footer, :styles, :action)) .merge(params) end
bubbles(resources, **params) { |resource, index| ... }
click to toggle source
# File lib/kamiflex/core.rb, line 20 def bubbles(resources, **params) resources.each_with_index do |resource, index| attributes, _contents = flex_scope{ yield(resource, index) } @flex_contents << { type: "bubble", }.merge(attributes.slice(:size, :direction, :header, :hero, :body, :footer, :styles, :action)) .merge(params) end end
carousel() { || ... }
click to toggle source
# File lib/kamiflex/core.rb, line 30 def carousel attributes, _contents = flex_scope{ yield } @flex_contents << { type: "carousel", contents: _contents } end
flex() { || ... }
click to toggle source
# File lib/kamiflex/core.rb, line 3 def flex attributes, _contents = flex_scope{ yield } { type: "flex", altText: "this is a flex message", contents: _contents.first }.merge(attributes.slice(:quickReply, :altText)) end
header(**params) { || ... }
click to toggle source
bubble attributes
# File lib/kamiflex/core.rb, line 39 def header(**params) _attributes, contents = flex_scope{ yield } @flex_attributes[:header] = { type: "box", layout: "vertical", contents: contents }.merge(params) end
hero(image_url, **params)
click to toggle source
# File lib/kamiflex/core.rb, line 48 def hero(image_url, **params) @flex_attributes[:hero] = { "type": "image", "url": image_url }.merge(params) end
horizontal_box(resources = [nil], **params) { |resource, index| ... }
click to toggle source
container
# File lib/kamiflex/core.rb, line 83 def horizontal_box(resources = [nil], **params) resources.each_with_index do |resource, index| _attributes, contents = flex_scope{ yield(resource, index) } if block_given? @flex_contents << { type: "box", layout: "horizontal", contents: contents || [] }.merge(params) end end
styles(params)
click to toggle source
style
# File lib/kamiflex/core.rb, line 74 def styles(params) @flex_attributes[:styles] = params end
vertical_box(resources = [nil], **params, &block)
click to toggle source
# File lib/kamiflex/core.rb, line 94 def vertical_box(resources = [nil], **params, &block) horizontal_box(resources, layout: "vertical", **params, &block) end
Private Instance Methods
flex_scope() { |self| ... }
click to toggle source
# File lib/kamiflex/core.rb, line 104 def flex_scope parent_attributes, parent_contents = @flex_attributes, @flex_contents @flex_attributes, @flex_contents = {}, [] yield self [@flex_attributes, @flex_contents] ensure @flex_attributes, @flex_contents = parent_attributes, parent_contents end