class Fractify::Operator
Attributes
executed[RW]
operator_character[RW]
rank[RW]
to_left[RW]
to_right[RW]
Public Class Methods
new(operator_character, rank, to_left = nil, to_right = nil)
click to toggle source
# File lib/fractify/operator.rb, line 8 def initialize(operator_character, rank, to_left = nil, to_right = nil) if to_left && !to_left.is_a?(Fractify::Fraction) || to_right && !to_right.is_a?(Fractify::Fraction) raise IncorrectArgumentsError end self.operator_character = operator_character self.rank = rank self.to_left = to_left self.to_right = to_right self.executed = false end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/fractify/operator.rb, line 20 def <=>(other) raise IncorrectArgumentsError unless other.is_a? Fractify::Operator return 0 if rank == other.rank return 1 if rank > other.rank -1 end
decrease_rank!(number = 1)
click to toggle source
# File lib/fractify/operator.rb, line 32 def decrease_rank!(number = 1) @rank -= number end
executed!()
click to toggle source
# File lib/fractify/operator.rb, line 40 def executed! self.executed = true end
executed?()
click to toggle source
# File lib/fractify/operator.rb, line 44 def executed? executed end
increase_rank!(number = 1)
click to toggle source
# File lib/fractify/operator.rb, line 36 def increase_rank!(number = 1) @rank += number end
not_executed?()
click to toggle source
# File lib/fractify/operator.rb, line 48 def not_executed? !executed end
to_s()
click to toggle source
# File lib/fractify/operator.rb, line 28 def to_s "(#{operator_character}, #{rank})" end