SIValue 0.0.0
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 +7 -0
 - data/lib/sivalue.rb +22 -0
 - metadata +44 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: cf2a6a1cea518b9018bbbcafd1100d990872c626
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 0761b85fbba25d4d2e1d1a0f2a6a0f4131096985
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 1dee3ed2235b2b950723c51cce2fa5d8b15e508ca685d8ec3d07bde9be1351407530b8e61f47fa4c7ffc60aca952fcc4aa69873d9e047e0592d4ca437276b436
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: be70179ccf63b8863ec1651d9f6a34489938126df8794947d8a8284833b15e1250197e4d97d7045eea3444b0f87cdb8ef0174d5f7438456651e202a1181f3384
         
     | 
    
        data/lib/sivalue.rb
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'bigdecimal'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module SIValue
         
     | 
| 
      
 4 
     | 
    
         
            +
              PREFIX_MAGNITUDES = {
         
     | 
| 
      
 5 
     | 
    
         
            +
                'm' => 6, 'k' => 3, 'b' => 9
         
     | 
| 
      
 6 
     | 
    
         
            +
              }
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              # Returns BigDecimal
         
     | 
| 
      
 9 
     | 
    
         
            +
              def self.from(str)
         
     | 
| 
      
 10 
     | 
    
         
            +
                _, num, prefix = str.match(/^([-+]?[0-9]*\.?[0-9]*)(#{PREFIX_MAGNITUDES.keys.join('|')})?/oi).to_a
         
     | 
| 
      
 11 
     | 
    
         
            +
                if num
         
     | 
| 
      
 12 
     | 
    
         
            +
                  if prefix
         
     | 
| 
      
 13 
     | 
    
         
            +
                    BigDecimal.new(num) * 10**PREFIX_MAGNITUDES[prefix]
         
     | 
| 
      
 14 
     | 
    
         
            +
                  else
         
     | 
| 
      
 15 
     | 
    
         
            +
                    BigDecimal.new(num)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
                else
         
     | 
| 
      
 18 
     | 
    
         
            +
                  0.0
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
              end  
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,44 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: SIValue
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Aria Edmonds
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-04-20 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies: []
         
     | 
| 
      
 13 
     | 
    
         
            +
            description: Very simple, only has thousand, millions, billions
         
     | 
| 
      
 14 
     | 
    
         
            +
            email: blackstab1337@gmail.com
         
     | 
| 
      
 15 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 16 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 17 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 18 
     | 
    
         
            +
            files:
         
     | 
| 
      
 19 
     | 
    
         
            +
            - lib/sivalue.rb
         
     | 
| 
      
 20 
     | 
    
         
            +
            homepage: http://rubygems.org/gems/sivalue
         
     | 
| 
      
 21 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 22 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 23 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 24 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 25 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 26 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 27 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 28 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 30 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 31 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 32 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 33 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 34 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 35 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 36 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 37 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 38 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 39 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 40 
     | 
    
         
            +
            rubygems_version: 2.6.8
         
     | 
| 
      
 41 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 42 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 43 
     | 
    
         
            +
            summary: Converts an abbreviated number string to a number
         
     | 
| 
      
 44 
     | 
    
         
            +
            test_files: []
         
     |