lib/hotcell/node.rb in hotcell-0.0.1 vs lib/hotcell/node.rb in hotcell-0.1.0

- old
+ new

@@ -1,38 +1,49 @@ module Hotcell class Node attr_accessor :name, :children, :options + attr_reader :position, :source def self.build *args new(*args).optimize end def initialize name, *args @name = name @options = args.extract_options! + @source = @options.delete(:source) + @position = @options.delete(:position) @children = args end + def position_info + source.info(position).values_at(:line, :column) + end + def optimize self end def [] key children[key] end def render context - process context, *render_nodes(context, children) + process context, *render_children(context) end def process context, *values raise NotImplementedError end def render_nodes context, *values values.flatten.map do |node| node.is_a?(Hotcell::Node) ? node.render(context) : node end + end + + def render_children context + render_nodes context, children end def == other other.is_a?(self.class) && name == other.name &&