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 a input command

Examples:

input :grammar     => {:value => '[5 DIGITS]', :content_type => 'application/grammar+voxeo'},
      :mode        => :speech,
      :recognizer  => 'es-es'

returns:
  <input xmlns="urn:xmpp:rayo:input:1" mode="speech" recognizer="es-es">
    <grammar content-type="application/grammar+voxeo">[5 DIGITS]</choices>
  </input>

Parameters:

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

Options Hash (options):

  • :grammar (Grammar, Hash)

    the grammar to activate

  • :max_silence (Integer, optional)

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

  • :min_confidence (Float, optional)

    with which to consider a response acceptable

  • :mode (Symbol, optional)

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

  • :recognizer (String, optional)

    to use for speech recognition

  • :terminator (String, optional)

    by which to signal the end of input

  • :sensitivity (Float, optional)

    Indicates how sensitive the interpreter should be to loud versus quiet input. Higher values represent greater sensitivity.

  • :initial_timeout (Integer, optional)

    Indicates the amount of time preceding input which may expire before a timeout is triggered.

  • :inter_digit_timeout (Integer, optional)

    Indicates (in the case of DTMF input) the amount of time between input digits which may expire before a timeout is triggered.

Returns:

  • (Command::Input)

    a formatted Rayo input command



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

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

Instance Method Details

#grammarGrammar

Returns the grammar to activate.

Returns:

  • (Grammar)

    the grammar to activate



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

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

#grammar=(other) ⇒ Object

Parameters:

  • other (Hash)

Options Hash (other):

  • :content_type (String)

    the document content type

  • :value (String)

    the grammar doucment

  • :url (String)

    the url from which to fetch the grammar



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

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

#initial_timeoutInteger

Returns Indicates the amount of time preceding input which may expire before a timeout is triggered.

Returns:

  • (Integer)

    Indicates the amount of time preceding input which may expire before a timeout is triggered.



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

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

#initial_timeout=(other) ⇒ Object

Parameters:

  • timeout (Integer)

    Indicates the amount of time preceding input which may expire before a timeout is triggered.



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

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

#inspect_attributesObject

:nodoc:



173
174
175
# File 'lib/punchblock/component/input.rb', line 173

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

#inter_digit_timeoutInteger

Returns Indicates (in the case of DTMF input) the amount of time between input digits which may expire before a timeout is triggered.

Returns:

  • (Integer)

    Indicates (in the case of DTMF input) the amount of time between input digits which may expire before a timeout is triggered.



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

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

#inter_digit_timeout=(other) ⇒ Object

Parameters:

  • timeout (Integer)

    Indicates (in the case of DTMF input) the amount of time between input digits which may expire before a timeout is triggered.



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

def inter_digit_timeout=(other)
  write_attr :'inter-digit-timeout', 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



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

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



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

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



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

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



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

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



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

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



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

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

#recognizerString

Returns recognizer to use for speech recognition.

Returns:

  • (String)

    recognizer to use for speech recognition



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

def recognizer
  read_attr :recognizer
end

#recognizer=(recognizer) ⇒ Object

Parameters:

  • recognizer (String)

    to use for speech recognition



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

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

#sensitivityFloat

Returns Indicates how sensitive the interpreter should be to loud versus quiet input. Higher values represent greater sensitivity.

Returns:

  • (Float)

    Indicates how sensitive the interpreter should be to loud versus quiet input. Higher values represent greater sensitivity.



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

def sensitivity
  read_attr :sensitivity, :to_f
end

#sensitivity=(other) ⇒ Object

Parameters:

  • other (Float)

    Indicates how sensitive the interpreter should be to loud versus quiet input. Higher values represent greater sensitivity.



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

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

#terminatorString

Returns terminator by which to signal the end of input.

Returns:

  • (String)

    terminator by which to signal the end of input



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

def terminator
  read_attr :terminator
end

#terminator=(terminator) ⇒ Object

Parameters:

  • terminator (String)

    by which to signal the end of input



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

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