Sha256: 452a41eb6c3818f3ef5704ec5f0fadf46ad01ee3b5963933f375586b35099436

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

Timeparser
==========

Allows you to parse times from a string using a treetop grammar. It's pretty basic.

Example
-------

    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('your time information')

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.2 Readme.md