Sha256: 13c1a414eccb38808439845cc99c0fb2da4215f079e333b55812c1a7bbff1ab0

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

= Little math pet

This is a simple math parser. It always returns in Float.

0.1 - It supports addition/subtraction, multiplication/division, exponents and brackets in their correct order.

== Examples

  LittleMathPet.new("5*12+8").calc # => 68.0
  LittleMathPet.new("5*(12+8)").calc # => 100.0
  
It also can handle variables
  LittleMathPet.new("5*a+8").calc(:a => 4) # => 28.0
  LittleMathPet.new("a*b+c^d").calc(:a => 4, :b => 3, :c => 2, :d => 5) # => 44.0

== Syntax

Mostly ruby (+ - * / ** and ()) but can also accept : for division, ^ for exponents and [] for bracketing. It will also not mind about spaces.

== Contributing to little-math-pet
 
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
* Fork the project
* Start a feature/bugfix branch
* Commit and push until you are happy with your contribution
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

== Copyright

Copyright (c) 2011 Kostas Karachalios. See LICENSE.txt for
further details.

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
little_math_pet-0.1.3 README.rdoc
little_math_pet-0.1.2 README.rdoc