Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Implement missing reverse of ActionView::Helpers::NumberHelper#number_to_human_size

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 rails Initial import September 03, 2011
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rspec
Octocat-spinner-32 .rvmrc
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 CHANGELOG.md
Octocat-spinner-32 Gemfile
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 human_size_to_number.gemspec
README.md

Je suis un developpeyr Breton!

Overview

About human_size_to_number

This gem implement the missing reverse of the ActionView::Helpers::NumberHelper#number_to_human_size.

Usage

> "0 Bytes".human_size_to_number                # => 0
> "123 Bytes".human_size_to_number              # => 123
> "1.12 KB".human_size_to_number                # => 1239
> "12.1 KB".human_size_to_number                # => 12390
> "1.18 MB".human_size_to_number                # => 1237320
> "1.15 GB".human_size_to_number                # => 1234803098
> "1.12 TB".human_size_to_number                # => 1231453023109
> "lorem".human_size_to_number                  # => nil
> "lorem".human_size_to_number(:raise => true)  # => String::InvalidSizeStringError: String::InvalidSizeStringError
                                                             from ./lib/human_size_to_number/helper.rb:18:in `human_size_to_number'
                                                             from (irb):3
                                                             from :0

Project Tracking

Compatibility

human_size_to_number is tested against REE, ruby-head, jruby, 1.8.7, 1.9.2, 1.9.3.

Build Status

Build History

License

Copyright (c) 2011 Guillaume Hain

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Credits

Guillaume Hain: zedtux at zedroot dot com

Something went wrong with that request. Please try again.