Class: Formula

Inherits:
Object
  • Object
show all
Defined in:
lib/hypatia/formula.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operations) ⇒ Formula



4
5
6
# File 'lib/hypatia/formula.rb', line 4

def initialize(operations)
  @operations = operations
end

Instance Attribute Details

#operationsObject (readonly)

Returns the value of attribute operations.



2
3
4
# File 'lib/hypatia/formula.rb', line 2

def operations
  @operations
end

#resultObject (readonly)

Returns the value of attribute result.



2
3
4
# File 'lib/hypatia/formula.rb', line 2

def result
  @result
end

Instance Method Details

#difficultyObject



16
17
18
19
20
21
22
# File 'lib/hypatia/formula.rb', line 16

def difficulty
  if @operations.length > 0
    FormulaDifficultyCalculator.new(self).difficulty
  else
    nil
  end
end

#textObject



8
9
10
# File 'lib/hypatia/formula.rb', line 8

def text
  @operations.map(&:text).join(" \n ")
end