Giter VIP home page Giter VIP logo

nickel's Introduction

Nickel extracts date, time, and message information from naturally worded text.

Install

gem install nickel

Usage

A single occurrence

n = Nickel.parse("use the force on july 1st at 9am", Time.now)
n.message                       #=> "use the force"
n.occurrences.first.start_date  #=> "20110701"

A daily occurrence

n = Nickel.parse "wake up everyday at 11am"
n.message                       # => wake up
n.occurrences[0].type           # => daily
n.occurrences[0].start_time     # => 11:00:00

A weekly occurrence

n = Nickel.parse "guitar lessons every tuesday at 5pm"
n.message                       # => guitar lessons
n.occurrences[0].type           # => weekly
n.occurrences[0].day_of_week    # => tue
n.occurrences[0].interval       # => 1
n.occurrences[0].start_time     # => 17:00:00

A day monthly occurrence

n = Nickel.parse "drink specials on the second thursday of every month"
n.message                       # => drink specials
n.occurrences[0].type           # => daymonthly
n.occurrences[0].day_of_week    # => thu
n.occurrences[0].week_of_month  # => 2
n.occurrences[0].interval       # => 1

A date monthly occurrence

n = Nickel.parse "pay credit card every month on the 22nd"
n.message                       # => pay credit card
n.occurrences[0].type           # => datemonthly
n.occurrences[0].date_of_month  # => 22
n.occurrences[0].interval       # => 1

Multiple occurrences

n = Nickel.parse "band meeting every monday and wednesday at 2pm"
n.message                       # => band meeting
n.occurrences[0].type           # => weekly
n.occurrences[0].day_of_week    # => mon
n.occurrences[0].start_time     # => 14:00:00
n.occurrences[1].type           # => weekly
n.occurrences[1].day_of_week    # => wed
n.occurrences[1].start_time     # => 14:00:00

Setting current time

n = Nickel.parse "lunch 3 days from now", DateTime.new(2010,3,31)
n.message                       # => lunch
n.occurrences[0].start_date     # => 20100403

Running Tests

$ rake test

If you do not have RUBYOPT set: $ RUBYOPT=‘rubygems’ rake test

Copyright © 2008-2011 Lou Zell, released under the MIT license

nickel's People

Contributors

jeffcarbs avatar lzell avatar paulbjensen avatar retro avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.