Class: Estreet::UnaryExpression

Inherits:
Expression show all
Defined in:
lib/estreet/unary_expression.rb

Instance Attribute Summary

Attributes inherited from Node

#source_location

Instance Method Summary collapse

Methods inherited from Expression

#[], #call, coerce, #property, #to_expression, #to_statement

Methods inherited from Node

#as_json, #loc, #type

Constructor Details

#initialize(operator, argument) ⇒ UnaryExpression

Returns a new instance of UnaryExpression.



3
4
5
6
7
8
# File 'lib/estreet/unary_expression.rb', line 3

def initialize(operator, argument)
  Estreet.assert_valid_operator(UNARY_OPERATORS, operator)

  @operator = operator
  @argument = argument.to_expression
end

Instance Method Details

#attributesObject



10
11
12
13
14
15
16
# File 'lib/estreet/unary_expression.rb', line 10

def attributes
  super.merge(
    operator: @operator,
    argument: @argument,
    prefix: true # TODO: when is it false?
  )
end