Class: SignalWire::Contexts::GatherQuestion

Inherits:
Object
  • Object
show all
Defined in:
lib/signalwire/contexts/context_builder.rb

Overview

Represents a single question in a gather_info configuration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key:, question:, type: 'string', confirm: false, prompt: nil, functions: nil) ⇒ GatherQuestion

Returns a new instance of GatherQuestion.



31
32
33
34
35
36
37
38
# File 'lib/signalwire/contexts/context_builder.rb', line 31

def initialize(key:, question:, type: 'string', confirm: false, prompt: nil, functions: nil)
  @key       = key
  @question  = question
  @type      = type
  @confirm   = confirm
  @prompt    = prompt
  @functions = functions
end

Instance Attribute Details

#confirmObject

Returns the value of attribute confirm.



29
30
31
# File 'lib/signalwire/contexts/context_builder.rb', line 29

def confirm
  @confirm
end

#functionsObject

Returns the value of attribute functions.



29
30
31
# File 'lib/signalwire/contexts/context_builder.rb', line 29

def functions
  @functions
end

#keyObject

Returns the value of attribute key.



29
30
31
# File 'lib/signalwire/contexts/context_builder.rb', line 29

def key
  @key
end

#promptObject

Returns the value of attribute prompt.



29
30
31
# File 'lib/signalwire/contexts/context_builder.rb', line 29

def prompt
  @prompt
end

#questionObject

Returns the value of attribute question.



29
30
31
# File 'lib/signalwire/contexts/context_builder.rb', line 29

def question
  @question
end

#typeObject

Returns the value of attribute type.



29
30
31
# File 'lib/signalwire/contexts/context_builder.rb', line 29

def type
  @type
end

Instance Method Details

#to_hObject



40
41
42
43
44
45
46
47
# File 'lib/signalwire/contexts/context_builder.rb', line 40

def to_h
  h = { "key" => @key, "question" => @question }
  h["type"]      = @type      if @type != 'string'
  h["confirm"]   = true       if @confirm
  h["prompt"]    = @prompt    if @prompt
  h["functions"] = @functions if @functions
  h
end