lib/undies/node.rb in undies-1.2.0 vs lib/undies/node.rb in undies-2.0.0

- old
+ new

@@ -1,38 +1,30 @@ module Undies + class Node - attr_reader :___content + # have as many methods to the class level as possilbe to keep from + # polluting the public instance methods and to maximize the effectiveness + # of the Element#method_missing logic - def initialize(content) - @___content = content + def self.content(node) + node.instance_variable_get("@content") end - def start_tag - nil + def self.flush(output, node) + output << self.content(node) end - def end_tag - nil + def initialize(content) + @start_tag = nil + @end_tag = nil + @content = content end - def to_s(pp_level=0, pp_indent=nil) - [ self.start_tag, - self.___content, - self.end_tag - ].compact.collect do |item| - pretty_print(item, pp_level, pp_indent) - end.join - end - - private - - def pretty_print(data, level, indent) - if data.kind_of? NodeList - data.to_s(level+1, indent) - else - indent ? "#{' '*level*indent}#{data}\n" : data - end + def ==(other_node) + self.class.content(self) == other_node.class.content(other_node) && + self.instance_variable_get("@start_tag") == other_node.instance_variable_get("@start_tag") && + self.instance_variable_get("@end_tag") == other_node.instance_variable_get("@end_tag") end end end