Class: Punchblock::Component::Input

Inherits:
ComponentNode show all
Defined in:
lib/punchblock/component/input.rb

Defined Under Namespace

Classes: Complete, Grammar

Constant Summary

Constants inherited from RayoNode

RayoNode::InvalidNodeError

Instance Attribute Summary

Attributes inherited from RayoNode

#client, #component_id, #connection, #domain, #original_component, #target_call_id, #target_mixer_name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ComponentNode

#add_event, #complete_event, #complete_event=, #initialize, #register_event_handler, #register_internal_handlers, #response=, #stop!, #stop_action, #trigger_event_handler, #write_action

Methods inherited from Punchblock::CommandNode

#initialize, #response, #response=, #write_attr

Methods inherited from RayoNode

class_from_registration, #eql?, import, #inspect, register, #source

Constructor Details

This class inherits a constructor from Punchblock::Component::ComponentNode

Class Method Details

.new(options = {}) ⇒ Command::Input

Create an input message

Examples:

input :prompt      => {:text => 'Please enter your postal code.', :voice => 'simon'},
      :choices     => {:value => '[5 DIGITS]'},
      :timeout     => 30,
      :recognizer  => 'es-es'

returns:
  <input xmlns="urn:xmpp:tropo:input:1" timeout="30" recognizer="es-es">
    <prompt voice='simon'>Please enter your postal code.</prompt>
    <choices content-type="application/grammar+voxeo">[5 DIGITS]</choices>
  </input>

Parameters:

  • options (Hash) (defaults to: {})

    for inputing/prompting a specific call

Options Hash (options):

  • :choices (Choices, Hash)

    to allow the user to input

  • :prompt (Prompt, Hash, Optional)

    to play/read to the caller as the question

  • :mode (Symbol, Optional)

    by which to accept input. Can be :speech, :dtmf or :any

  • :timeout (Integer, Optional)

    to wait for user input

  • :bargein (Boolean, Optional)

    wether or not to allow the caller to begin their response before the prompt finishes

  • :recognizer (String, Optional)

    to use for speech recognition

  • :terminator (String, Optional)

    by which to signal the end of input

  • :min_confidence (Float, Optional)

    with which to consider a response acceptable

Returns:

  • (Command::Input)

    a formatted Rayo input command



35
36
37
38
39
# File 'lib/punchblock/component/input.rb', line 35

def self.new(options = {})
  super().tap do |new_node|
    options.each_pair { |k,v| new_node.send :"#{k}=", v }
  end
end

Instance Method Details

#complete_timeoutInteger

Returns timeout to wait for user input.

Returns:

  • (Integer)

    timeout to wait for user input



184
185
186
# File 'lib/punchblock/component/input.rb', line 184

def complete_timeout
  read_attr :'complete-timeout', :to_i
end

#complete_timeout=(other) ⇒ Object

Parameters:

  • timeout (Integer)

    to wait for user input



191
192
193
# File 'lib/punchblock/component/input.rb', line 191

def complete_timeout=(other)
  write_attr :'complete-timeout', other
end

#grammarChoices

Returns the choices available.

Returns:

  • (Choices)

    the choices available



212
213
214
215
# File 'lib/punchblock/component/input.rb', line 212

def grammar
  node = find_first 'ns:grammar', :ns => self.class.registered_ns
  Grammar.new node if node
end

#grammar=(other) ⇒ Object

Parameters:

  • choices (Hash)


222
223
224
225
226
227
# File 'lib/punchblock/component/input.rb', line 222

def grammar=(other)
  return unless other
  remove_children :grammar
  grammar = Grammar.new(other) unless other.is_a?(Grammar)
  self << grammar
end

#incomplete_timeoutInteger

Returns timeout to wait for user input.

Returns:

  • (Integer)

    timeout to wait for user input



198
199
200
# File 'lib/punchblock/component/input.rb', line 198

def incomplete_timeout
  read_attr :'incomplete-timeout', :to_i
end

#incomplete_timeout=(other) ⇒ Object

Parameters:

  • timeout (Integer)

    to wait for user input



205
206
207
# File 'lib/punchblock/component/input.rb', line 205

def incomplete_timeout=(other)
  write_attr :'incomplete-timeout', other
end

#initial_timeoutInteger

Returns timeout to wait for user input.

Returns:

  • (Integer)

    timeout to wait for user input



142
143
144
# File 'lib/punchblock/component/input.rb', line 142

def initial_timeout
  read_attr :'initial-timeout', :to_i
end

#initial_timeout=(other) ⇒ Object

Parameters:

  • timeout (Integer)

    to wait for user input



149
150
151
# File 'lib/punchblock/component/input.rb', line 149

def initial_timeout=(other)
  write_attr :'initial-timeout', other
end

#inspect_attributesObject

:nodoc:



229
230
231
# File 'lib/punchblock/component/input.rb', line 229

def inspect_attributes # :nodoc:
  [:mode, :terminator, :max_digits, :recognizer, :initial_timeout, :inter_digit_timeout, :term_timeout, :complete_timeout, :incomplete_timeout, :sensitivity, :min_confidence, :grammar] + super
end

#inter_digit_timeoutInteger

Returns timeout to wait for user input.

Returns:

  • (Integer)

    timeout to wait for user input



156
157
158
# File 'lib/punchblock/component/input.rb', line 156

def inter_digit_timeout
  read_attr :'inter-digit-timeout', :to_i
end

#inter_digit_timeout=(other) ⇒ Object

Parameters:

  • timeout (Integer)

    to wait for user input



163
164
165
# File 'lib/punchblock/component/input.rb', line 163

def inter_digit_timeout=(other)
  write_attr :'inter-digit-timeout', other
end

#max_digitsBoolean

Returns wether or not to allow the caller to begin their response before the prompt finishes.

Returns:

  • (Boolean)

    wether or not to allow the caller to begin their response before the prompt finishes



44
45
46
# File 'lib/punchblock/component/input.rb', line 44

def max_digits
  read_attr :'max-digits', :to_i
end

#max_digits=(other) ⇒ Object

Parameters:

  • bargein (Boolean)

    wether or not to allow the caller to begin their response before the prompt finishes



51
52
53
# File 'lib/punchblock/component/input.rb', line 51

def max_digits=(other)
  write_attr :'max-digits', other
end

#max_silenceInteger

Returns the amount of time in milliseconds that an input command will wait until considered that a silence becomes a NO-MATCH.

Returns:

  • (Integer)

    the amount of time in milliseconds that an input command will wait until considered that a silence becomes a NO-MATCH



58
59
60
# File 'lib/punchblock/component/input.rb', line 58

def max_silence
  read_attr :'max-silence', :to_i
end

#max_silence=(other) ⇒ Object

Parameters:

  • other (Integer)

    the amount of time in milliseconds that an input command will wait until considered that a silence becomes a NO-MATCH



65
66
67
# File 'lib/punchblock/component/input.rb', line 65

def max_silence=(other)
  write_attr :'max-silence', other
end

#min_confidenceFloat

Returns Confidence with which to consider a response acceptable.

Returns:

  • (Float)

    Confidence with which to consider a response acceptable



72
73
74
# File 'lib/punchblock/component/input.rb', line 72

def min_confidence
  read_attr 'min-confidence', :to_f
end

#min_confidence=(min_confidence) ⇒ Object

Parameters:

  • min_confidence (Float)

    with which to consider a response acceptable



79
80
81
# File 'lib/punchblock/component/input.rb', line 79

def min_confidence=(min_confidence)
  write_attr 'min-confidence', min_confidence
end

#modeSymbol

Returns mode by which to accept input. Can be :speech, :dtmf or :any.

Returns:

  • (Symbol)

    mode by which to accept input. Can be :speech, :dtmf or :any



86
87
88
# File 'lib/punchblock/component/input.rb', line 86

def mode
  read_attr :mode, :to_sym
end

#mode=(mode) ⇒ Object

Parameters:

  • mode (Symbol)

    by which to accept input. Can be :speech, :dtmf or :any



93
94
95
# File 'lib/punchblock/component/input.rb', line 93

def mode=(mode)
  write_attr :mode, mode
end

#recognizerString

Returns recognizer to use for speech recognition.

Returns:

  • (String)

    recognizer to use for speech recognition



100
101
102
# File 'lib/punchblock/component/input.rb', line 100

def recognizer
  read_attr :recognizer
end

#recognizer=(recognizer) ⇒ Object

Parameters:

  • recognizer (String)

    to use for speech recognition



107
108
109
# File 'lib/punchblock/component/input.rb', line 107

def recognizer=(recognizer)
  write_attr :recognizer, recognizer
end

#sensitivityInteger

Returns timeout to wait for user input.

Returns:

  • (Integer)

    timeout to wait for user input



128
129
130
# File 'lib/punchblock/component/input.rb', line 128

def sensitivity
  read_attr :sensitivity, :to_f
end

#sensitivity=(other) ⇒ Object

Parameters:

  • timeout (Integer)

    to wait for user input



135
136
137
# File 'lib/punchblock/component/input.rb', line 135

def sensitivity=(other)
  write_attr :sensitivity, other
end

#term_timeoutInteger

Returns timeout to wait for user input.

Returns:

  • (Integer)

    timeout to wait for user input



170
171
172
# File 'lib/punchblock/component/input.rb', line 170

def term_timeout
  read_attr :'term-timeout', :to_i
end

#term_timeout=(other) ⇒ Object

Parameters:

  • timeout (Integer)

    to wait for user input



177
178
179
# File 'lib/punchblock/component/input.rb', line 177

def term_timeout=(other)
  write_attr :'term-timeout', other
end

#terminatorString

Returns terminator by which to signal the end of input.

Returns:

  • (String)

    terminator by which to signal the end of input



114
115
116
# File 'lib/punchblock/component/input.rb', line 114

def terminator
  read_attr :terminator
end

#terminator=(terminator) ⇒ Object

Parameters:

  • terminator (String)

    by which to signal the end of input



121
122
123
# File 'lib/punchblock/component/input.rb', line 121

def terminator=(terminator)
  write_attr :terminator, terminator
end