Class: Punchblock::Component::Input::Grammar
Constant Summary
Constants inherited from RayoNode
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
-
#content_type ⇒ String
The document content type.
- #content_type=(content_type) ⇒ Object
-
#inspect_attributes ⇒ Object
:nodoc:.
-
#url ⇒ String
The URL from which the fetch the grammar.
- #url=(other) ⇒ Object
-
#value ⇒ String, RubySpeech::GRXML::Grammar
The grammar document.
- #value=(value) ⇒ Object
Methods inherited from RayoNode
class_from_registration, #eql?, import, #inspect, register, #source
Class Method Details
.new(options = {}) ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/punchblock/component/input.rb', line 184 def self.new( = {}) super(:grammar).tap do |new_node| case when Nokogiri::XML::Node new_node.inherit when Hash new_node.content_type = [:content_type] new_node.value = [:value] new_node.url = [:url] end end end |
Instance Method Details
#content_type ⇒ String
Returns the document content type.
200 201 202 |
# File 'lib/punchblock/component/input.rb', line 200 def content_type read_attr 'content-type' end |
#content_type=(content_type) ⇒ Object
207 208 209 |
# File 'lib/punchblock/component/input.rb', line 207 def content_type=(content_type) write_attr 'content-type', content_type || grxml_content_type end |
#inspect_attributes ⇒ Object
:nodoc:
248 249 250 |
# File 'lib/punchblock/component/input.rb', line 248 def inspect_attributes # :nodoc: [:content_type, :value, :url] + super end |
#url ⇒ String
Returns the URL from which the fetch the grammar.
237 238 239 |
# File 'lib/punchblock/component/input.rb', line 237 def url read_attr 'url' end |
#url=(other) ⇒ Object
244 245 246 |
# File 'lib/punchblock/component/input.rb', line 244 def url=(other) write_attr 'url', other end |
#value ⇒ String, RubySpeech::GRXML::Grammar
Returns the grammar document.
213 214 215 216 217 218 219 220 |
# File 'lib/punchblock/component/input.rb', line 213 def value return nil unless content.present? if grxml? RubySpeech::GRXML.import content else content end end |
#value=(value) ⇒ Object
224 225 226 227 228 229 230 231 232 |
# File 'lib/punchblock/component/input.rb', line 224 def value=(value) return unless value if grxml? && !value.is_a?(RubySpeech::GRXML::Element) value = RubySpeech::GRXML.import value end Nokogiri::XML::Builder.with(self) do |xml| xml.cdata " #{value} " end end |