Class: Janeway::AST::UnaryOperator

Inherits:
Expression show all
Defined in:
lib/janeway/ast/unary_operator.rb

Overview

Represent unary operators “!”, “-”

Instance Attribute Summary collapse

Attributes inherited from Expression

#value

Instance Method Summary collapse

Methods inherited from Expression

#indented, #literal?, #singular_query?, #type

Constructor Details

#initialize(operator, operand = nil) ⇒ UnaryOperator



9
10
11
12
13
# File 'lib/janeway/ast/unary_operator.rb', line 9

def initialize(operator, operand = nil)
  super()
  @operator = operator
  @operand = operand
end

Instance Attribute Details

#operandObject

Returns the value of attribute operand.



7
8
9
# File 'lib/janeway/ast/unary_operator.rb', line 7

def operand
  @operand
end

#operatorObject

Returns the value of attribute operator.



7
8
9
# File 'lib/janeway/ast/unary_operator.rb', line 7

def operator
  @operator
end

Instance Method Details

#to_sObject



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