tippy_mun 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/Gemfile.lock +1 -1
 - data/lib/tippy_mun/builder.rb +31 -29
 - data/lib/tippy_mun/version.rb +1 -1
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 13a0cc101e3663b44603f1085e46cf961e90635b
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 30c6ab5da1f4c9c2b2b971ce190302f0986b135e
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a402264573bf39868cdc3c1e88cc23dfff399314348e20a5b99d79981db6f7164062a117f3770b6ba05927de51888127c439048f8627488c33a3883ab6b1fc17
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: b368023e0c407cff24308860d7256b585779fd2756cfeeb9a882b3e93f517ee48761eaa3ff4599fad029516259e99dfc196c5e3e40e503c8114a88a4a1f105c9
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/lib/tippy_mun/builder.rb
    CHANGED
    
    | 
         @@ -1,36 +1,38 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class String
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
      
 2 
     | 
    
         
            +
            	  def integer? 
         
     | 
| 
      
 3 
     | 
    
         
            +
            			    return true if self =~ /^[1-9]\d*(\.\d+)?$/
         
     | 
| 
      
 4 
     | 
    
         
            +
            					    false
         
     | 
| 
      
 5 
     | 
    
         
            +
            							  end
         
     | 
| 
       6 
6 
     | 
    
         
             
            end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
            module  
     | 
| 
       9 
     | 
    
         
            -
            	class Builder
         
     | 
| 
       10 
     | 
    
         
            -
            		def initialize (total, gratuity)
         
     | 
| 
       11 
     | 
    
         
            -
            			@total = total
         
     | 
| 
       12 
     | 
    
         
            -
            			@gratuity = gratuity
         
     | 
| 
       13 
     | 
    
         
            -
            		end
         
     | 
| 
       14 
     | 
    
         
            -
            		
         
     | 
| 
       15 
     | 
    
         
            -
            		def generate
         
     | 
| 
       16 
     | 
    
         
            -
            			return calculation if number_based?
         
     | 
| 
       17 
     | 
    
         
            -
            			string_based
         
     | 
| 
       18 
     | 
    
         
            -
            		end
         
     | 
| 
      
 8 
     | 
    
         
            +
            module Tippy
         
     | 
| 
       19 
9 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
      
 10 
     | 
    
         
            +
            	  class Builder
         
     | 
| 
      
 11 
     | 
    
         
            +
            			    def initialize total:, gratuity:
         
     | 
| 
      
 12 
     | 
    
         
            +
            						      @total = total
         
     | 
| 
      
 13 
     | 
    
         
            +
            						      @gratuity = gratuity
         
     | 
| 
      
 14 
     | 
    
         
            +
            									    end
         
     | 
| 
       23 
15 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
      
 16 
     | 
    
         
            +
            					    def generate
         
     | 
| 
      
 17 
     | 
    
         
            +
            								      return calculation if number_based?
         
     | 
| 
      
 18 
     | 
    
         
            +
            											      string_based
         
     | 
| 
      
 19 
     | 
    
         
            +
            														    end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            							    def number_based?
         
     | 
| 
      
 22 
     | 
    
         
            +
            										      (@gratuity.is_a? Numeric) || (@gratuity.integer?)
         
     | 
| 
      
 23 
     | 
    
         
            +
            													    end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            									    def string_based
         
     | 
| 
      
 26 
     | 
    
         
            +
            												      case @gratuity.downcase
         
     | 
| 
      
 27 
     | 
    
         
            +
            																      when 'high'     then calculation 25
         
     | 
| 
      
 28 
     | 
    
         
            +
            																				      when 'standard' then calculation 18
         
     | 
| 
      
 29 
     | 
    
         
            +
            																								      when 'low'      then calculation 15
         
     | 
| 
      
 30 
     | 
    
         
            +
            																												      end
         
     | 
| 
      
 31 
     | 
    
         
            +
            															    end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            											    def calculation gratuity = @gratuity
         
     | 
| 
      
 34 
     | 
    
         
            +
            														      @total += @total * (gratuity.to_f / 100)
         
     | 
| 
      
 35 
     | 
    
         
            +
            																	    end
         
     | 
| 
      
 36 
     | 
    
         
            +
            													  end
         
     | 
| 
       31 
37 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
            		def calculation gratuity = @gratuity
         
     | 
| 
       33 
     | 
    
         
            -
            			@total += @total * (gratuity.to_f / 100)
         
     | 
| 
       34 
     | 
    
         
            -
            		end
         
     | 
| 
       35 
     | 
    
         
            -
            	end
         
     | 
| 
       36 
38 
     | 
    
         
             
            end
         
     | 
    
        data/lib/tippy_mun/version.rb
    CHANGED