Sha256: eaa30ca02b3cde2905506692862967bed00f5c049de9a3db5e906d3c9e53f676

Contents?: true

Size: 271 Bytes

Versions: 8

Compression:

Stored size: 271 Bytes

Contents

module Slapp
  module Helpers
    def convert_to_bytes(string)
      units = {
        :'K' => 1024,
        :'MB' => 1024 * 1024
      }

      formula = units.map {|u| u.last if string.include? u.first.to_s }.compact
      string.to_i * formula.first
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
slapp-0.2.3 lib/slapp/helpers.rb
slapp-0.2.2 lib/slapp/helpers.rb
slapp-0.2.1 lib/slapp/helpers.rb
slapp-0.2.0 lib/slapp/helpers.rb
slapp-0.1.3 lib/slapp/helpers.rb
slapp-0.1.2 lib/slapp/helpers.rb
slapp-0.1.1 lib/slapp/helpers.rb
slapp-0.1.0 lib/slapp/helpers.rb