lib/ruby_speech/ssml/element.rb in ruby_speech-0.1.2 vs lib/ruby_speech/ssml/element.rb in ruby_speech-0.1.3
- old
+ new
@@ -1,20 +1,24 @@
module RubySpeech
module SSML
class Element < Niceogiri::XML::Node
def self.new(element_name, atts = {}, &block)
- super element_name do |new_node|
+ 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)
+ new_node << new_node.encode_special_chars(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)
+ if const == String
+ self << encode_special_chars(args.first)
+ else
+ self << const.new(*args, &block)
+ end
else
super
end
end