Sha256: d4d0c23c64a88bcc911361cdccea724425dbf27b024a76f219d249cf0f45468b

Contents?: true

Size: 1.61 KB

Versions: 8

Compression:

Stored size: 1.61 KB

Contents

module VoiceBase
  class JSON::Word
    attr_accessor :sequence
    attr_accessor :start_time
    attr_accessor :end_time
    attr_accessor :confidence
    attr_accessor :word
    attr_accessor :error
    attr_accessor :metadata

    alias_method :p, :sequence
    alias_method :p=, :sequence=
    alias_method :c, :confidence
    alias_method :c=, :confidence=
    alias_method :s, :start_time
    alias_method :s=, :start_time=
    alias_method :e, :end_time
    alias_method :e=, :end_time=
    alias_method :w, :word
    alias_method :w=, :word=
    alias_method :m, :metadata
    alias_method :m=, :metadata=

    def initialize(options={})
      options.each do |k,v|
        self.send("#{k}=",v)
      end
    end

    def clone
      clone = VoiceBase::JSON::Word.new
      clone.sequence   = sequence
      clone.start_time = start_time
      clone.end_time   = end_time
      clone.confidence = confidence
      clone.error      = error
      clone.word       = word
      clone.metadata   = metadata
      clone
    end

    def ==(word)
      self.sequence   == word.sequence &&
      self.start_time == word.start_time &&
      self.end_time   == word.end_time &&
      self.confidence == word.confidence &&
      self.word       == word.word &&
      self.metadata   == word.metadata
    end

    def empty?
      sequence.nil? && start_time.nil? && end_time.nil? && (word.nil? || word.empty?)
    end

    def to_hash
      {"p": sequence, "c": confidence, "s": start_time, "e": end_time, "w": word}
    end

    def to_json
      {"p": sequence, "c": confidence, "s": start_time, "e": end_time, "w": word}.to_json
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
voicebase-client-ruby-1.2.1 lib/voicebase/json/word.rb
voicebase-client-ruby-1.2.0 lib/voicebase/json/word.rb
voicebase-client-ruby-1.1.1 lib/voicebase/json/word.rb
voicebase-client-ruby-1.1.0 lib/voicebase/json/word.rb
voicebase-client-ruby-1.0.17 lib/voicebase/json/word.rb
voicebase-client-ruby-1.0.16 lib/voicebase/json/word.rb
voicebase-client-ruby-1.0.15 lib/voicebase/json/word.rb
voicebase-client-ruby-1.0.14 lib/voicebase/json/word.rb