Class: AdHocTemplate::Parser::IterationNode

Inherits:
TagNode
  • Object
show all
Defined in:
lib/ad_hoc_template/parser.rb

Defined Under Namespace

Classes: InnerLabel

Instance Attribute Summary

Attributes inherited from TagNode

#type

Instance Method Summary collapse

Methods inherited from TagNode

#cast, #contains_any_fallback_tag?, #contains_any_value_tag?, #format_sub_nodes, #inner_iteration_tag_labels, #push, #select_fallback_nodes

Instance Method Details

#assign_value_to_type(first_leaf) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
# File 'lib/ad_hoc_template/parser.rb', line 99

def assign_value_to_type(first_leaf)
  return first_leaf unless first_leaf.kind_of? String

  if /\A[^\s:]*:\s/ =~ first_leaf
    @type, remaining_part = first_leaf.split(/:(?:#{LINE_END_STR}|\s)/, 2)
    @type = @type.empty? ? nil : '#' + @type
    return remaining_part
  end

  first_leaf.sub(/\A#{LINE_END_STR}/, '')
end

#contains_any_value_assigned_tag_node?(record) ⇒ Boolean

Returns:

  • (Boolean)


111
112
113
114
115
116
# File 'lib/ad_hoc_template/parser.rb', line 111

def contains_any_value_assigned_tag_node?(record)
  return not_empty_sub_records?(record) if type
  each_tag_node do |node|
    return true if node.contains_any_value_assigned_tag_node?(record)
  end
end

#inner_labelsObject



118
119
120
121
122
# File 'lib/ad_hoc_template/parser.rb', line 118

def inner_labels
  return unless @type
  labels = inner_iteration_tag_labels
  InnerLabel.labels(labels, @type) if labels
end