convers_money 1.0.0 → 1.0.1
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/convers_money.gemspec +1 -1
- data/lib/convers_money.rb +47 -28
- data/lib/convers_money/version.rb +1 -1
- metadata +4 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: e550192aacf950e861c7051c8341dd915412ce02
         | 
| 4 | 
            +
              data.tar.gz: 1db1f09cfdff2c3b34225bd3d5cd89fa735abb23
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: dd519d7aa9f932620e369b7684e854fb9f2ef60d824278969f68231182ecb8c255ce93923a426c446eddd0f63600a0fab5fec9a542a410aeefc3d85d41b27866
         | 
| 7 | 
            +
              data.tar.gz: fea2c1b35cad3d7511af1a2f6be016ab7d773f1d9e7796ca5419b209bf112eb26800cd95b73d6e761afd40db4e8a08463c4f2ede87063b9eeac2663a09f784b7
         | 
    
        data/convers_money.gemspec
    CHANGED
    
    | @@ -10,7 +10,7 @@ Gem::Specification.new do |spec| | |
| 10 10 | 
             
              spec.email         = ['antonelo@gmail.com']
         | 
| 11 11 |  | 
| 12 12 | 
             
              spec.summary       = 'Money conversor'
         | 
| 13 | 
            -
              spec.description   = "ConversMoney it's a Money Conversor given by fixed currency and change rates of your choice. \n  | 
| 13 | 
            +
              spec.description   = "ConversMoney it's a Money Conversor given by fixed currency and change rates of your choice. \r\n From the version and further '1.0.1' it's a full working version"
         | 
| 14 14 | 
             
              spec.homepage      = 'https://github.com/nelantone/convers_money'
         | 
| 15 15 | 
             
              spec.license       = 'MIT'
         | 
| 16 16 |  | 
    
        data/lib/convers_money.rb
    CHANGED
    
    | @@ -56,58 +56,77 @@ class ConversMoney | |
| 56 56 | 
             
                "#{format('%.2f', @amount)} #{@currency}"
         | 
| 57 57 | 
             
              end
         | 
| 58 58 |  | 
| 59 | 
            -
              def  | 
| 60 | 
            -
                if other.is_a? Float
         | 
| 61 | 
            -
                   | 
| 59 | 
            +
              def convert_to_reference_currency(other, currency)
         | 
| 60 | 
            +
                if (other.is_a? Float ) || (other.is_a? Integer)
         | 
| 61 | 
            +
                  ConversMoney.new( other, currency)
         | 
| 62 | 
            +
                else
         | 
| 63 | 
            +
                  other.convert_to(currency)
         | 
| 62 64 | 
             
                end
         | 
| 63 65 | 
             
              end
         | 
| 64 66 |  | 
| 67 | 
            +
              # def resut_conversion(other, currency, total_amount)
         | 
| 68 | 
            +
              #   result = ConversMoney.new(total_amount.round(2), currency)
         | 
| 69 | 
            +
              #   if other.amount.is_a? Integer
         | 
| 70 | 
            +
              #     result.amount = result.amount.to_i
         | 
| 71 | 
            +
              #     result
         | 
| 72 | 
            +
              #   end
         | 
| 73 | 
            +
              # end
         | 
| 74 | 
            +
             | 
| 65 75 | 
             
              def +(other)
         | 
| 66 | 
            -
                 | 
| 67 | 
            -
             | 
| 76 | 
            +
                other = convert_to_reference_currency(other, currency)
         | 
| 77 | 
            +
                total_amount = amount + other.amount
         | 
| 78 | 
            +
                result = ConversMoney.new(total_amount.round(2), currency)
         | 
| 79 | 
            +
                if other.amount.is_a? Integer
         | 
| 80 | 
            +
                  result.amount = result.amount.to_i
         | 
| 81 | 
            +
                  result
         | 
| 82 | 
            +
                else
         | 
| 83 | 
            +
                  result
         | 
| 68 84 | 
             
                end
         | 
| 69 | 
            -
                total_amount = amount + other.convert_to(currency).amount
         | 
| 70 | 
            -
                ConversMoney.new(total_amount.to_f.round(2), currency)
         | 
| 71 85 | 
             
              end
         | 
| 72 86 |  | 
| 73 87 | 
             
              def -(other)
         | 
| 74 | 
            -
                 | 
| 75 | 
            -
             | 
| 88 | 
            +
                other = convert_to_reference_currency(other, currency)
         | 
| 89 | 
            +
                total_amount = amount - other.amount
         | 
| 90 | 
            +
                result = ConversMoney.new(total_amount.round(2), currency)
         | 
| 91 | 
            +
                if other.amount.is_a? Integer
         | 
| 92 | 
            +
                  result.amount = result.amount.to_i
         | 
| 93 | 
            +
                  result
         | 
| 94 | 
            +
                else
         | 
| 95 | 
            +
                  result
         | 
| 76 96 | 
             
                end
         | 
| 77 | 
            -
                total_amount = amount - other.convert_to(currency).amount
         | 
| 78 | 
            -
                ConversMoney.new(total_amount.to_f.round(2), currency)
         | 
| 79 97 | 
             
              end
         | 
| 80 98 |  | 
| 81 99 | 
             
              def *(other)
         | 
| 82 | 
            -
                 | 
| 83 | 
            -
             | 
| 100 | 
            +
                other = convert_to_reference_currency(other, currency)
         | 
| 101 | 
            +
                total_amount = amount * other.amount
         | 
| 102 | 
            +
                result = ConversMoney.new(total_amount.round(2), currency)
         | 
| 103 | 
            +
                if other.amount.is_a? Integer
         | 
| 104 | 
            +
                  result.amount = result.amount.to_i
         | 
| 105 | 
            +
                  result
         | 
| 106 | 
            +
                else
         | 
| 107 | 
            +
                  result
         | 
| 84 108 | 
             
                end
         | 
| 85 | 
            -
                total_amount = amount * other.convert_to(currency).amount
         | 
| 86 | 
            -
                ConversMoney.new(total_amount.to_f.round(2), currency)
         | 
| 87 109 | 
             
              end
         | 
| 88 110 |  | 
| 89 111 | 
             
              def /(other)
         | 
| 90 | 
            -
                 | 
| 91 | 
            -
             | 
| 112 | 
            +
                other = convert_to_reference_currency(other, currency)
         | 
| 113 | 
            +
                total_amount = amount / other.amount
         | 
| 114 | 
            +
                result = ConversMoney.new(total_amount.round(2), currency)
         | 
| 115 | 
            +
                if other.amount.is_a? Integer
         | 
| 116 | 
            +
                  result.amount = result.amount.to_i
         | 
| 117 | 
            +
                  result
         | 
| 118 | 
            +
                else
         | 
| 119 | 
            +
                  result
         | 
| 92 120 | 
             
                end
         | 
| 93 | 
            -
                total_amount = amount / other.convert_to(currency).amount
         | 
| 94 | 
            -
                ConversMoney.new(total_amount.to_f.round(2), currency)
         | 
| 95 121 | 
             
              end
         | 
| 96 122 |  | 
| 97 123 | 
             
              def <=>(other)
         | 
| 98 124 | 
             
                if other.is_a? Float
         | 
| 99 125 | 
             
                  other = ConversMoney.new( other.round(2), currency)
         | 
| 100 | 
            -
                end
         | 
| 101 | 
            -
                amount.round(2) <=> other.convert_to(currency).amount.round(2)
         | 
| 102 | 
            -
              end
         | 
| 103 | 
            -
             | 
| 104 | 
            -
              def self.checking_fixed_currency(other, currency)
         | 
| 105 | 
            -
                if other.currency.eql?(currency)
         | 
| 106 | 
            -
                  other
         | 
| 107 126 | 
             
                else
         | 
| 108 | 
            -
                   | 
| 109 | 
            -
                  other.convert_to(currency)
         | 
| 127 | 
            +
                  other = convert_to_reference_currency(other, currency)
         | 
| 110 128 | 
             
                end
         | 
| 129 | 
            +
                amount.round(2) <=> other.amount.round(2)
         | 
| 111 130 | 
             
              end
         | 
| 112 131 |  | 
| 113 132 | 
             
              def self.conversion_rates_access
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: convers_money
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0. | 
| 4 | 
            +
              version: 1.0.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Toño Serna
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2017-02- | 
| 11 | 
            +
            date: 2017-02-13 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -99,7 +99,8 @@ dependencies: | |
| 99 99 | 
             
                  - !ruby/object:Gem::Version
         | 
| 100 100 | 
             
                    version: 4.6.0
         | 
| 101 101 | 
             
            description: "ConversMoney it's a Money Conversor given by fixed currency and change
         | 
| 102 | 
            -
              rates of your choice. \n  | 
| 102 | 
            +
              rates of your choice. \r\n From the version and further '1.0.1' it's a full working
         | 
| 103 | 
            +
              version"
         | 
| 103 104 | 
             
            email:
         | 
| 104 105 | 
             
            - antonelo@gmail.com
         | 
| 105 106 | 
             
            executables: []
         |