class Schnell::Builder

Public Class Methods

new(total:, gratuity: @total=total) click to toggle source
# File lib/schnell/builder.rb, line 3
def initialize total:, gratuity:
        @total=total
        @gratuity=gratuity
end

Public Instance Methods

calculation(gratuity=@gratuity) click to toggle source
# File lib/schnell/builder.rb, line 21
def calculation gratuity=@gratuity
        @total += @total *  (gratuity.to_f / 100)
end
generate() click to toggle source
# File lib/schnell/builder.rb, line 7
def generate
        return calculation if number_based?
        string_based
end
number_based?() click to toggle source
# File lib/schnell/builder.rb, line 11
def number_based?
        (@gratuity.is_a? Numeric) || (@gratuity.integer?)
end
string_based() click to toggle source
# File lib/schnell/builder.rb, line 14
def string_based
        case @gratuity.downcase
        when 'high'          then calculation 25
        when 'standard'      then calculation 18
        when 'low'           then calculation 15
        end
end