Class: Fabulator::Expr::UnaryExpr
- Inherits:
-
Object
- Object
- Fabulator::Expr::UnaryExpr
- Defined in:
- lib/fabulator/expr/unary_expr.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(e) ⇒ UnaryExpr
constructor
A new instance of UnaryExpr.
- #run(context, autovivify = false) ⇒ Object
Constructor Details
#initialize(e) ⇒ UnaryExpr
Returns a new instance of UnaryExpr.
4 5 6 |
# File 'lib/fabulator/expr/unary_expr.rb', line 4 def initialize(e) @expr = e end |
Instance Method Details
#run(context, autovivify = false) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/fabulator/expr/unary_expr.rb', line 8 def run(context, autovivify = false) l = @expr.run(context, autovivify) l = [ l ] unless l.is_a?(Array) l = l.collect { |i| i.value }.uniq - [ nil ] return @expr.collect{|e| Fabulator::Expr::Node.new( context.root.axis, context.root.roots, self.calculate(e), [] ) } end |