class LineParser::Node

Attributes

end_tag[R]
start_tag[R]
start_tag_to_subnode[R]
subnode_classes[R]
tokens_to_be_ignored[R]
node_below[RW]
subnodes[R]

Public Class Methods

new() click to toggle source
# File lib/log_line_parser/line_parser.rb, line 133
def initialize
  @subnodes = []
  @self_class = self.class
  @cannot_ignore = @self_class.tokens_to_be_ignored.empty?
end
register_subnode_classes(*subnode_classes) click to toggle source
# File lib/log_line_parser/line_parser.rb, line 115
def register_subnode_classes(*subnode_classes)
  @subnode_classes = subnode_classes
  subnode_classes.each do |subnode|
    @start_tag_to_subnode[subnode.start_tag] = subnode
  end
end
setup(start_tag, end_tag, to_be_ignored=[]) click to toggle source
# File lib/log_line_parser/line_parser.rb, line 122
def setup(start_tag, end_tag, to_be_ignored=[])
  @start_tag_to_subnode = {}
  @tokens_to_be_ignored = []
  @start_tag = start_tag
  @end_tag = end_tag
  @tokens_to_be_ignored.concat(to_be_ignored) if to_be_ignored
end

Public Instance Methods

accept(visitor, memo=nil) click to toggle source
# File lib/log_line_parser/line_parser.rb, line 139
def accept(visitor, memo=nil)
  visitor.visit(self, memo)
end
can_ignore?(token) click to toggle source
# File lib/log_line_parser/line_parser.rb, line 155
def can_ignore?(token)
  if @cannot_ignore
    false
  else
    @self_class.tokens_to_be_ignored.include?(token)
  end
end
end_tag?(token) click to toggle source
# File lib/log_line_parser/line_parser.rb, line 151
def end_tag?(token)
  @self_class.end_tag == token
end
push(token) click to toggle source
# File lib/log_line_parser/line_parser.rb, line 163
def push(token)
  @subnodes.push token
end
subnode_class(token) click to toggle source
# File lib/log_line_parser/line_parser.rb, line 147
def subnode_class(token)
  @self_class.start_tag_to_subnode[token]
end
to_s() click to toggle source
# File lib/log_line_parser/line_parser.rb, line 143
def to_s
  @subnodes.join
end