class AdHocTemplate::Parser::TagNode
Attributes
type[R]
Public Instance Methods
cast(node_type=Parser::TagNode)
click to toggle source
# File lib/ad_hoc_template/parser.rb, line 46 def cast(node_type=Parser::TagNode) node_type.new.concat(clone) end
contains_any_fallback_tag?()
click to toggle source
# File lib/ad_hoc_template/parser.rb, line 30 def contains_any_fallback_tag? any? {|sub_node| sub_node.kind_of? Parser::FallbackNode } end
contains_any_value_assigned_tag_node?(record)
click to toggle source
# File lib/ad_hoc_template/parser.rb, line 20 def contains_any_value_assigned_tag_node?(record) each_tag_node do |node| return true if node.contains_any_value_assigned_tag_node?(record) end end
contains_any_value_tag?()
click to toggle source
# File lib/ad_hoc_template/parser.rb, line 26 def contains_any_value_tag? each_tag_node {|node| return true if node.contains_any_value_tag? } end
format_sub_nodes(data_loader, memo)
click to toggle source
# File lib/ad_hoc_template/parser.rb, line 55 def format_sub_nodes(data_loader, memo) map {|leaf| leaf.accept(data_loader, memo) }.join end
inner_iteration_tag_labels()
click to toggle source
# File lib/ad_hoc_template/parser.rb, line 34 def inner_iteration_tag_labels names = [] each_tag_node do |node| next unless node.kind_of? IterationNode names.push node.type if node.type inner_names = node.inner_iteration_tag_labels names.concat inner_names if inner_names end names unless names.empty? end
push(node=TreeStack::Node.new)
click to toggle source
Calls superclass method
# File lib/ad_hoc_template/parser.rb, line 14 def push(node=TreeStack::Node.new) first_leaf = node[0] node[0] = assign_value_to_type(first_leaf) if empty? && first_leaf super end
select_fallback_nodes()
click to toggle source
# File lib/ad_hoc_template/parser.rb, line 50 def select_fallback_nodes nodes = select {|sub_node| sub_node.kind_of? Parser::FallbackNode } nodes.empty? ? nil : nodes end
Private Instance Methods
assign_value_to_type(first_leaf)
click to toggle source
# File lib/ad_hoc_template/parser.rb, line 66 def assign_value_to_type(first_leaf) if first_leaf.kind_of?(String) && /\A\s/ =~ first_leaf return first_leaf.sub(/\A#{LINE_END_STR}/, '') end @type, first_leaf_content = split_by_newline_or_spaces(first_leaf) first_leaf_content || '' end
each_tag_node() { |node| ... }
click to toggle source
# File lib/ad_hoc_template/parser.rb, line 61 def each_tag_node each {|node| yield node if node.kind_of?(TagNode) } false end
split_by_newline_or_spaces(first_leaf)
click to toggle source
# File lib/ad_hoc_template/parser.rb, line 74 def split_by_newline_or_spaces(first_leaf) sep = /\A\S*#{LINE_END_STR}/ =~ first_leaf ? LINE_END_RE : /\s+/ first_leaf.split(sep, 2) end