Sha256: 02ea2b8ee05c6b8ca01ef01ef3ea6fb1e06e1c8fbe369be4e6e7e74106d433e1

Contents?: true

Size: 887 Bytes

Versions: 6

Compression:

Stored size: 887 Bytes

Contents

require 'ruby_speech/generic_element'

module RubySpeech
  module SSML
    class Element
      def self.namespace
        SSML_NAMESPACE
      end

      def self.root_element
        Speak
      end

      def self.module
        SSML
      end

      include GenericElement

      def to_doc
        document
      end

      private

      def get_time_attribute(key)
        value = read_attr(key)

        if value.nil?
          nil
        elsif value.end_with?('ms')
          value.to_f / 1000
        else
          value.to_f
        end
      end

      def set_time_attribute(key, value)
        raise ArgumentError, "You must specify a valid #{key} (positive float value in seconds)" unless value.is_a?(Numeric) && value >= 0
        self[key] = value == value.round ? "#{value.to_i}s" : "#{(value * 1000).to_i}ms"
      end
    end # Element
  end # SSML
end # RubySpeech

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby_speech-3.0.1-java lib/ruby_speech/ssml/element.rb
ruby_speech-3.0.1 lib/ruby_speech/ssml/element.rb
ruby_speech-3.0.0-java lib/ruby_speech/ssml/element.rb
ruby_speech-3.0.0 lib/ruby_speech/ssml/element.rb
ruby_speech-2.4.0-java lib/ruby_speech/ssml/element.rb
ruby_speech-2.4.0 lib/ruby_speech/ssml/element.rb