Class: Plivo::Component

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type: nil, sub_type: nil, index: nil, parameters: nil) ⇒ Component

Returns a new instance of Component.



26
27
28
29
30
31
# File 'lib/plivo/template.rb', line 26

def initialize(type: nil, sub_type: nil, index: nil, parameters: nil)
  @type = type
  @sub_type = sub_type
  @index = index
  @parameters = parameters
end

Instance Attribute Details

#indexObject

Returns the value of attribute index.



24
25
26
# File 'lib/plivo/template.rb', line 24

def index
  @index
end

#parametersObject

Returns the value of attribute parameters.



24
25
26
# File 'lib/plivo/template.rb', line 24

def parameters
  @parameters
end

#sub_typeObject

Returns the value of attribute sub_type.



24
25
26
# File 'lib/plivo/template.rb', line 24

def sub_type
  @sub_type
end

#typeObject

Returns the value of attribute type.



24
25
26
# File 'lib/plivo/template.rb', line 24

def type
  @type
end

Instance Method Details

#to_hashObject



33
34
35
36
37
38
39
40
# File 'lib/plivo/template.rb', line 33

def to_hash
  {
    type: @type,
    sub_type: @sub_type,
    index: @index,
    parameters: @parameters&.map(&:to_hash)&.reject { |h| h.values.all?(&:nil?) }
  }.reject { |_, v| v.nil? }
end