class Structured::ParserStack
Attributes
element[RW]
parent[RW]
type[RW]
Public Class Methods
new(type:, element:, parent:)
click to toggle source
# File lib/structured/parser_stack.rb, line 5 def initialize(type:, element:, parent:) @type = type @element = element @parent = parent end
root(type)
click to toggle source
# File lib/structured/parser_stack.rb, line 36 def self.root(type) new(type: type, element: nil, parent: nil) end
Public Instance Methods
path()
click to toggle source
# File lib/structured/parser_stack.rb, line 15 def path if root? type.type_name elsif element.nil? # abtract elements like Step use no element, they just forward parsing to a concrete type. parent.path else parent.path + parent.type.format_stack_frame_element(element) end end
Also aliased as: to_s
push(element, type)
click to toggle source
# File lib/structured/parser_stack.rb, line 11 def push(element, type) self.class.new(type: type, element: element, parent: self) end
root()
click to toggle source
# File lib/structured/parser_stack.rb, line 32 def root root? ? self : parent.root end
root?()
click to toggle source
# File lib/structured/parser_stack.rb, line 28 def root? parent.nil? end