Class: RubySpeech::NLSML::Builder
- Inherits:
-
Object
- Object
- RubySpeech::NLSML::Builder
- Defined in:
- lib/ruby_speech/nlsml/builder.rb
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ Builder
constructor
A new instance of Builder.
- #interpretation(*args, &block) ⇒ Object
- #method_missing(method_name, *args, &block) ⇒ Object
Constructor Details
#initialize(options = {}, &block) ⇒ Builder
Returns a new instance of Builder.
6 7 8 9 10 11 12 13 14 |
# File 'lib/ruby_speech/nlsml/builder.rb', line 6 def initialize( = {}, &block) = {'xmlns' => NLSML_NAMESPACE}.merge() xml_doc = Nokogiri::XML::Builder.new do |builder| builder.result do |r| apply_block r, &block end end.doc @document = RubySpeech::NLSML::Document.new xml_doc end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
23 24 25 |
# File 'lib/ruby_speech/nlsml/builder.rb', line 23 def method_missing(method_name, *args, &block) @result.send method_name, *args, &block end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
4 5 6 |
# File 'lib/ruby_speech/nlsml/builder.rb', line 4 def document @document end |
Instance Method Details
#interpretation(*args, &block) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/ruby_speech/nlsml/builder.rb', line 16 def interpretation(*args, &block) if args.last.respond_to?(:has_key?) && args.last.has_key?(:confidence) args.last[:confidence] = args.last[:confidence].to_f end @result.send :interpretation, *args, &block end |