Class: TestSemano::Builder
- Inherits:
-
Object
- Object
- TestSemano::Builder
- Defined in:
- lib/test_semano/builder.rb
Instance Method Summary collapse
- #calculation(graduity = @graduity) ⇒ Object
- #generate ⇒ Object
-
#initialize(total:, graduity:) ⇒ Builder
constructor
A new instance of Builder.
- #number_based ⇒ Object
- #string_based ⇒ Object
Constructor Details
#initialize(total:, graduity:) ⇒ Builder
Returns a new instance of Builder.
10 11 12 13 |
# File 'lib/test_semano/builder.rb', line 10 def initialize(total:, graduity:) @total = total @graduity = graduity end |
Instance Method Details
#calculation(graduity = @graduity) ⇒ Object
32 33 34 |
# File 'lib/test_semano/builder.rb', line 32 def calculation graduity = @graduity @total += @total * (@graduity.to_f/100) end |
#generate ⇒ Object
15 16 17 18 |
# File 'lib/test_semano/builder.rb', line 15 def generate return calculation if number_based string_based end |
#number_based ⇒ Object
20 21 22 |
# File 'lib/test_semano/builder.rb', line 20 def number_based (@graduity.is_a? Numeric) || (@graduity.integer?) end |
#string_based ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/test_semano/builder.rb', line 24 def string_based case @graduity.downcase when "low" then calculation 15 when "high" then calculation 25 when "standard" then calculation 18 end end |