Class: TestSemano::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/test_semano/builder.rb

Instance Method Summary collapse

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

#generateObject



15
16
17
18
# File 'lib/test_semano/builder.rb', line 15

def generate
 return calculation if number_based
 string_based
end

#number_basedObject



20
21
22
# File 'lib/test_semano/builder.rb', line 20

def number_based
  (@graduity.is_a? Numeric) || (@graduity.integer?)
end

#string_basedObject



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