Class: Plivo::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/plivo/interactive.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(buttons: nil, sections: nil) ⇒ Action

Returns a new instance of Action.



75
76
77
78
# File 'lib/plivo/interactive.rb', line 75

def initialize(buttons: nil, sections: nil)
  @buttons = buttons ? buttons.map { |b| Buttons.new(**b) } : []
  @sections = sections ? sections.map { |s| Section.new(**s) } : []
end

Instance Attribute Details

#buttonsObject

Returns the value of attribute buttons.



73
74
75
# File 'lib/plivo/interactive.rb', line 73

def buttons
  @buttons
end

#sectionsObject

Returns the value of attribute sections.



73
74
75
# File 'lib/plivo/interactive.rb', line 73

def sections
  @sections
end

Instance Method Details

#to_hashObject



80
81
82
83
84
85
# File 'lib/plivo/interactive.rb', line 80

def to_hash
  {
    buttons: @buttons.map(&:to_hash),
    sections: @sections.map(&:to_hash),
  }.reject { |_, v| v.nil? }
end