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 210 |
# File 'lib/punchblock/component/input.rb', line 207 def content_type=(content_type) return unless content_type write_attr 'content-type', content_type end |
#inspect_attributes ⇒ Object
:nodoc:
250 251 252 |
# File 'lib/punchblock/component/input.rb', line 250 def inspect_attributes # :nodoc: [:content_type, :value, :url] + super end |
#url ⇒ String
Returns the URL from which the fetch the grammar.
239 240 241 |
# File 'lib/punchblock/component/input.rb', line 239 def url read_attr 'url' end |
#url=(other) ⇒ Object
246 247 248 |
# File 'lib/punchblock/component/input.rb', line 246 def url=(other) write_attr 'url', other end |
#value ⇒ String, RubySpeech::GRXML::Grammar
Returns the grammar document.
214 215 216 217 218 219 220 221 |
# File 'lib/punchblock/component/input.rb', line 214 def value return nil unless content.present? if grxml? RubySpeech::GRXML.import content else content end end |
#value=(value) ⇒ Object
225 226 227 228 229 230 231 232 233 234 |
# File 'lib/punchblock/component/input.rb', line 225 def value=(value) return unless value self.content_type = grxml_content_type unless self.content_type 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 |