Sha256: 31526839eff4ea164d72fd5c9e07ec6e5d88defec2b0c1c738d72897bea646db

Contents?: true

Size: 836 Bytes

Versions: 2

Compression:

Stored size: 836 Bytes

Contents

module RubySpeech
  module SSML
    class Element < Niceogiri::XML::Node
      def self.new(element_name, atts = {}, &block)
        super element_name do |new_node|
          atts.each_pair { |k, v| new_node.send :"#{k}=", v }
          block_return = new_node.instance_eval &block if block_given?
          new_node << block_return if block_return.is_a?(String)
        end
      end

      def method_missing(method_name, *args, &block)
        const_name = method_name.to_s.sub('ssml', '').titleize.gsub(' ', '')
        const = SSML.const_get const_name
        if const && self.class::VALID_CHILD_TYPES.include?(const)
          self << const.new(*args, &block)
        else
          super
        end
      end

      def eql?(o, *args)
        super o, :content, *args
      end
    end # Element
  end # SSML
end # RubySpeech

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby_speech-0.1.2 lib/ruby_speech/ssml/element.rb
ruby_speech-0.1.1 lib/ruby_speech/ssml/element.rb