class NewGem::Builder

Public Class Methods

new(total:, gratuity: @total = total) click to toggle source

Your code goes here…

# File lib/new_gem/builder.rb, line 4
def initialize total:, gratuity:
  @total = total
  @gratuity = gratuity
end

Public Instance Methods

calculation(gratuity = @gratuity) click to toggle source
# File lib/new_gem/builder.rb, line 27
def calculation gratuity = @gratuity
  @total += @total * (gratuity.to_f / 100)
end
generate() click to toggle source
# File lib/new_gem/builder.rb, line 9
def generate
  return calculation if number_based?
  string_based
end
number_based?() click to toggle source
# File lib/new_gem/builder.rb, line 14
def number_based?
  (@gratuity.is_a? Numeric) || (@gratuity.integer?)

end
string_based() click to toggle source
# File lib/new_gem/builder.rb, line 19
def string_based
  case @gratuity.downcase
  when "high" then calculation 25
  when "standard" then calculation 18
  when "low" then calculation 15
  end
end