class CustomGem::Builder
Public Class Methods
new(total:, quantity: @total = total)
click to toggle source
# File lib/custom_gem/builder.rb, line 3 def initialize total:, quantity: @total = total @quantity = quantity end
Public Instance Methods
calculation(quantity = @quantity)
click to toggle source
# File lib/custom_gem/builder.rb, line 20 def calculation quantity = @quantity @total += @total * (@quantity.to_f / 100) end
generate()
click to toggle source
# File lib/custom_gem/builder.rb, line 7 def generate return calculation if number_based? string_based end
number_based?()
click to toggle source
# File lib/custom_gem/builder.rb, line 11 def number_based? (@quantity.is_a? Numeric) || (@quantity.interger?) end
string_based()
click to toggle source
# File lib/custom_gem/builder.rb, line 14 def string_based case @quantity.downcase when 'high' then calculation 25 when 'low' then calculation 18 end end