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.



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

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.



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

def index
  @index
end

#parametersObject

Returns the value of attribute parameters.



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

def parameters
  @parameters
end

#sub_typeObject

Returns the value of attribute sub_type.



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

def sub_type
  @sub_type
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#to_hashObject



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

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