Class: Numerouno::Combiner

Inherits:
Object
  • Object
show all
Defined in:
lib/numerouno/combiner.rb

Instance Method Summary collapse

Instance Method Details

#apply!Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/numerouno/combiner.rb', line 18

def apply!
  @numbers.each_with_index do |number, index|
    @current = index
    if number_is_correct_power?
      apply :*, to_left if should_multiply?
      apply :+, to_right if should_add?
    end 
  end
  
  @numbers.compact!
end

#of_power(power) ⇒ Object



13
14
15
16
# File 'lib/numerouno/combiner.rb', line 13

def of_power power
  @power = power
  self  
end