Class: Fabulator::Expr::RootContext

Inherits:
Object
  • Object
show all
Defined in:
lib/fabulator/expr/node.rb

Instance Method Summary collapse

Constructor Details

#initialize(axis = nil) ⇒ RootContext

Returns a new instance of RootContext.



147
148
149
# File 'lib/fabulator/expr/node.rb', line 147

def initialize(axis = nil)
  @axis = axis
end

Instance Method Details

#create_node(context) ⇒ Object



164
165
166
167
168
169
# File 'lib/fabulator/expr/node.rb', line 164

def create_node(context)
  if context.root.root(@axis).nil?
    context.root.roots[@axis] = Fabulator::Expr::Node.new(@axis,context.root.roots,nil,[])
  end
  context.root.root(@axis)
end

#run(context, autovivify = false) ⇒ Object



151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/fabulator/expr/node.rb', line 151

def run(context, autovivify = false)
  c = nil
  if @axis.is_a?(String)
    c = context.root.root(@axis)
  elsif !@axis.nil?
    c = @axis.run(context, autovivify).first
  else
    c = context.root.root
  end
  return [ ] if c.nil?
  return [ c ]
end