Class: Dentaku::AST::Modulo

Inherits:
Arithmetic show all
Defined in:
lib/dentaku/ast/arithmetic.rb

Instance Attribute Summary

Attributes inherited from Operation

#left, #right

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Arithmetic

#initialize, #type

Methods inherited from Operation

#dependencies, #initialize, right_associative?

Methods inherited from Node

arity, #dependencies

Constructor Details

This class inherits a constructor from Dentaku::AST::Arithmetic

Class Method Details

.precedenceObject



136
137
138
# File 'lib/dentaku/ast/arithmetic.rb', line 136

def self.precedence
  20
end

Instance Method Details

#operatorObject



132
133
134
# File 'lib/dentaku/ast/arithmetic.rb', line 132

def operator
  :%
end

#percent?Boolean

Returns:

  • (Boolean)


120
121
122
# File 'lib/dentaku/ast/arithmetic.rb', line 120

def percent?
  left.nil?
end

#valid_left?Boolean

Returns:

  • (Boolean)


140
141
142
# File 'lib/dentaku/ast/arithmetic.rb', line 140

def valid_left?
  valid_node?(left) || left.nil?
end

#value(context = {}) ⇒ Object



124
125
126
127
128
129
130
# File 'lib/dentaku/ast/arithmetic.rb', line 124

def value(context={})
  if percent?
    cast(right.value(context)) * 0.01
  else
    super
  end
end