Sha256: 212761ae18f731772915ecf85dc5feaa52ebcf47d4a37fe19c75107778334b9d

Contents?: true

Size: 864 Bytes

Versions: 18

Compression:

Stored size: 864 Bytes

Contents

module RubySpeech
  module NLSML
    class Builder
      attr_reader :document

      def initialize(options = {}, &block)
        options = {'xmlns' => NLSML_NAMESPACE}.merge(options)
        @document = Nokogiri::XML::Builder.new do |builder|
          builder.result options do |r|
            apply_block r, &block
          end
        end.doc
      end

      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

      def method_missing(method_name, *args, &block)
        @result.send method_name, *args, &block
      end

      private

      def apply_block(result, &block)
        @result = result
        instance_eval &block
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
ruby_speech-2.3.1-java lib/ruby_speech/nlsml/builder.rb
ruby_speech-2.3.1 lib/ruby_speech/nlsml/builder.rb
ruby_speech-2.3.0-java lib/ruby_speech/nlsml/builder.rb
ruby_speech-2.3.0 lib/ruby_speech/nlsml/builder.rb
ruby_speech-2.2.2-java lib/ruby_speech/nlsml/builder.rb
ruby_speech-2.2.2 lib/ruby_speech/nlsml/builder.rb
ruby_speech-2.2.1-java lib/ruby_speech/nlsml/builder.rb
ruby_speech-2.2.1 lib/ruby_speech/nlsml/builder.rb
ruby_speech-2.2.0-java lib/ruby_speech/nlsml/builder.rb
ruby_speech-2.2.0 lib/ruby_speech/nlsml/builder.rb
ruby_speech-2.1.2-java lib/ruby_speech/nlsml/builder.rb
ruby_speech-2.1.2 lib/ruby_speech/nlsml/builder.rb
ruby_speech-2.1.1-java lib/ruby_speech/nlsml/builder.rb
ruby_speech-2.1.1 lib/ruby_speech/nlsml/builder.rb
ruby_speech-2.1.0-java lib/ruby_speech/nlsml/builder.rb
ruby_speech-2.1.0 lib/ruby_speech/nlsml/builder.rb
ruby_speech-2.0.2 lib/ruby_speech/nlsml/builder.rb
ruby_speech-2.0.1 lib/ruby_speech/nlsml/builder.rb