Class: Janeway::AST::UnaryOperator
- Inherits:
-
Expression
- Object
- Expression
- Janeway::AST::UnaryOperator
- Defined in:
- lib/janeway/ast/unary_operator.rb
Overview
Represent unary operators “!”, “-”
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#operand ⇒ Object
Returns the value of attribute operand.
Attributes inherited from Expression
Instance Method Summary collapse
-
#initialize(operator, operand = nil) ⇒ UnaryOperator
constructor
A new instance of UnaryOperator.
- #to_s ⇒ Object
- #tree(level) ⇒ Array
Methods inherited from Expression
#indented, #literal?, #singular_query?, #type
Constructor Details
#initialize(operator, operand = nil) ⇒ UnaryOperator
Returns a new instance of UnaryOperator.
9 10 11 12 13 |
# File 'lib/janeway/ast/unary_operator.rb', line 9 def initialize(operator, operand = nil) super() @name = operator # eg. :not @operand = operand end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/janeway/ast/unary_operator.rb', line 7 def name @name end |
#operand ⇒ Object
Returns the value of attribute operand.
7 8 9 |
# File 'lib/janeway/ast/unary_operator.rb', line 7 def operand @operand end |
Instance Method Details
#to_s ⇒ Object
15 16 17 |
# File 'lib/janeway/ast/unary_operator.rb', line 15 def to_s "#{@operator} #{operand}" end |
#tree(level) ⇒ Array
21 22 23 |
# File 'lib/janeway/ast/unary_operator.rb', line 21 def tree(level) indented(level, "#{operator}#{operand}") end |