Class: Code::Node::LeftOperation::Operator

Inherits:
Code::Node show all
Defined in:
lib/code/node/left_operation.rb

Constant Summary collapse

DOT =
"."
COLON_COLON =
"::"
AMPERSAND_DOT =
"&."
OR_KEYWORD =
"or"
PIPE_PIPE =
"||"
AND_KEYWORD =
"and"
AMPERSAND_AMPERSAND =
"&&"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Code::Node

#evaluate, #resolve

Constructor Details

#initialize(parsed) ⇒ Operator

Returns a new instance of Operator.



17
18
19
20
21
22
# File 'lib/code/node/left_operation.rb', line 17

def initialize(parsed)
  return if parsed.blank?

  @operator = parsed.delete(:operator).presence
  @statement = Statement.new(parsed.delete(:statement).presence)
end

Instance Attribute Details

#operatorObject (readonly)

Returns the value of attribute operator.



15
16
17
# File 'lib/code/node/left_operation.rb', line 15

def operator
  @operator
end

#statementObject (readonly)

Returns the value of attribute statement.



15
16
17
# File 'lib/code/node/left_operation.rb', line 15

def statement
  @statement
end

Instance Method Details

#and?Boolean

Returns:



36
37
38
# File 'lib/code/node/left_operation.rb', line 36

def and?
  operator == AND_KEYWORD || operator == AMPERSAND_AMPERSAND
end

#call?Boolean

Returns:



24
25
26
# File 'lib/code/node/left_operation.rb', line 24

def call?
  operator == DOT || operator == COLON_COLON
end

#or?Boolean

Returns:



32
33
34
# File 'lib/code/node/left_operation.rb', line 32

def or?
  operator == OR_KEYWORD || operator == PIPE_PIPE
end

#safe_call?Boolean

Returns:



28
29
30
# File 'lib/code/node/left_operation.rb', line 28

def safe_call?
  operator == AMPERSAND_DOT
end