class AdHocTemplate::Parser::IterationNode

Public Instance Methods

assign_value_to_type(first_leaf) click to toggle source
# 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) click to toggle source
# 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_labels() click to toggle source
# 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

Private Instance Methods

not_empty_sub_records?(record) click to toggle source
# File lib/ad_hoc_template/parser.rb, line 126
def not_empty_sub_records?(record)
  sub_records = record[type]
  return false if sub_records.nil? || sub_records.empty?
  sub_records.each do |rec|
    return true if rec.values.any? {|val| val && !val.empty? }
  end
  false
end