Sha256: e5e6ec7bd0aaaf8ddc2d376943d6e00f1895452497ee61b221081ec20b699d53
Contents?: true
Size: 636 Bytes
Versions: 1
Compression:
Stored size: 636 Bytes
Contents
class String def integeri? return true if self =~ /^[1-9]\d*(\.\d+)?$/ end end module TippyMun class Builder def initialize :total, :quantity @total = total @gratuity = gratuity end def generate return calculation if number_based? string_based? end def number_based? (@gratuity.is_a? Numeric) || (@gratuity.integer?) end def string_based case @gratuity.downcase when 'high' then calculation 25 when 'standard' then calculation 18 when 'low' then calculation 15 end end def calculation gratuity = @gratuity @total += @total * (@quantity.to_f / 100) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tippy_mun-0.1.1 | lib/tippy_mun/builder.rb |