Class: Arithmetic::Operator

Inherits:
Object
  • Object
show all
Defined in:
lib/arithmetic/operators.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string, priority, function) ⇒ Operator

Returns a new instance of Operator.



5
6
7
8
9
# File 'lib/arithmetic/operators.rb', line 5

def initialize(string, priority, function)
  @string = string
  @priority = priority
  @function = function
end

Instance Attribute Details

#priorityObject (readonly)

Returns the value of attribute priority.



3
4
5
# File 'lib/arithmetic/operators.rb', line 3

def priority
  @priority
end

#stringObject (readonly)

Returns the value of attribute string.



3
4
5
# File 'lib/arithmetic/operators.rb', line 3

def string
  @string
end

Instance Method Details

#arityObject



19
20
21
# File 'lib/arithmetic/operators.rb', line 19

def arity
  @function.arity
end

#eval(*args) ⇒ Object



11
12
13
# File 'lib/arithmetic/operators.rb', line 11

def eval(*args)
  @function.call(*args)
end

#to_sObject



15
16
17
# File 'lib/arithmetic/operators.rb', line 15

def to_s
  @string
end