Class: Punchblock::Component::Input

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

Defined Under Namespace

Classes: Complete, Grammar

Instance Attribute Summary

Attributes inherited from ComponentNode

#complete_event

Attributes inherited from RayoNode

#call_id, #client, #component_id, #connection, #original_component

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ComponentNode

#add_event, #initialize, #register_event_handler, #register_initial_handlers, #response=, #stop!, #stop_action, #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



33
34
35
36
37
# File 'lib/punchblock/component/input.rb', line 33

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



168
169
170
# File 'lib/punchblock/component/input.rb', line 168

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

#complete_timeout=(other) ⇒ Object

Parameters:

  • timeout (Integer)

    to wait for user input



175
176
177
# File 'lib/punchblock/component/input.rb', line 175

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

#grammarChoices

Returns the choices available.

Returns:

  • (Choices)

    the choices available



196
197
198
# File 'lib/punchblock/component/input.rb', line 196

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

#grammar=(other) ⇒ Object

Parameters:



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

def grammar=(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



182
183
184
# File 'lib/punchblock/component/input.rb', line 182

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

#incomplete_timeout=(other) ⇒ Object

Parameters:

  • timeout (Integer)

    to wait for user input



189
190
191
# File 'lib/punchblock/component/input.rb', line 189

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



126
127
128
# File 'lib/punchblock/component/input.rb', line 126

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

#initial_timeout=(other) ⇒ Object

Parameters:

  • timeout (Integer)

    to wait for user input



133
134
135
# File 'lib/punchblock/component/input.rb', line 133

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

#inspect_attributesObject

:nodoc:



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

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

#inter_digit_timeoutInteger

Returns timeout to wait for user input.

Returns:

  • (Integer)

    timeout to wait for user input



140
141
142
# File 'lib/punchblock/component/input.rb', line 140

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



147
148
149
# File 'lib/punchblock/component/input.rb', line 147

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



42
43
44
# File 'lib/punchblock/component/input.rb', line 42

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



49
50
51
# File 'lib/punchblock/component/input.rb', line 49

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

#min_confidenceFloat

Returns Confidence with which to consider a response acceptable.

Returns:

  • (Float)

    Confidence with which to consider a response acceptable



56
57
58
# File 'lib/punchblock/component/input.rb', line 56

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



63
64
65
# File 'lib/punchblock/component/input.rb', line 63

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



70
71
72
# File 'lib/punchblock/component/input.rb', line 70

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



77
78
79
# File 'lib/punchblock/component/input.rb', line 77

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

#recognizerString

Returns recognizer to use for speech recognition.

Returns:

  • (String)

    recognizer to use for speech recognition



84
85
86
# File 'lib/punchblock/component/input.rb', line 84

def recognizer
  read_attr :recognizer
end

#recognizer=(recognizer) ⇒ Object

Parameters:

  • recognizer (String)

    to use for speech recognition



91
92
93
# File 'lib/punchblock/component/input.rb', line 91

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

#sensitivityInteger

Returns timeout to wait for user input.

Returns:

  • (Integer)

    timeout to wait for user input



112
113
114
# File 'lib/punchblock/component/input.rb', line 112

def sensitivity
  read_attr :sensitivity, :to_f
end

#sensitivity=(other) ⇒ Object

Parameters:

  • timeout (Integer)

    to wait for user input



119
120
121
# File 'lib/punchblock/component/input.rb', line 119

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



154
155
156
# File 'lib/punchblock/component/input.rb', line 154

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

#term_timeout=(other) ⇒ Object

Parameters:

  • timeout (Integer)

    to wait for user input



161
162
163
# File 'lib/punchblock/component/input.rb', line 161

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



98
99
100
# File 'lib/punchblock/component/input.rb', line 98

def terminator
  read_attr :terminator
end

#terminator=(terminator) ⇒ Object

Parameters:

  • terminator (String)

    by which to signal the end of input



105
106
107
# File 'lib/punchblock/component/input.rb', line 105

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