Sha256: 73cdb26c68eefe139299b862a30505e5971c20719f9345a6ad235283a43dac55
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 KB
Contents
Timeparser ========== Allows you to parse times from a string using a treetop grammar. It's pretty basic. Examples -------- Timeparser.parse("1h20m").to_i # => 80 Timeparser.parse("1h20m").hours # => 1 Timeparser.parse("1h20m").hours(:up) # => 2 Timeparser.parse("1h40m").hours(:down) # => 1 Timeparser.parse("1h20m").minutes # => 80 Installation ------------ Before installing this or another Gem I highly recommend using RVM and that you create a .rvmrc file for your project. touch .rvmrc && echo "rvm use 1.9.2-p270@yourproject --create" > .rvmrc Install the gem: gem install timeparser or add it to your Gemfile if you are using Bundler (recommended) gem 'timeparser' and then run bundle Usage ----- Timeparser.parse('2hours 30minutes') Timeparser extends String with a method called #parse_time, use it like this: "1h30m".parse_time each of these methods will return a Timeparser::Time instance. If you need the accumulated minutes that were parsed out of the string call the #to_i or #minutes methods. The Time instance also knows about hours, which you can access through the #hours method. #hours takes an argument which allows you to round up the hours based on the minutes. Default is rounding down. Run the specs ------------- git clone git://github.com/the-architect/timeparser.git cd timeparser bundle install rake You can view the coverage info generated by simplecov by opening the generated files after you ran the tests. open coverage/index.html
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
timeparser-0.0.3 | Readme.md |