exalted_math 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.rdoc +10 -12
  2. data/VERSION +1 -1
  3. data/exalted_math.gemspec +1 -1
  4. metadata +1 -1
data/README.rdoc CHANGED
@@ -5,35 +5,33 @@ implement simple (or not so simple) parsing of mathematics for Exalted character
5
5
  sheets. Although I'm sure it could be used for other simple math situations.
6
6
  It consists of two parts; parser and abstract syntax tree. The parser
7
7
  constructs the abstract syntax tree as it parses the input string. The AST can
8
- then be used to compute the value of the expression with a given context. The
9
- AST also has a simple method to simplify it if possible. The AST is based on an
10
- array class, which makes it very easy to serialize.
8
+ then be used to compute the value of the expression with a given context.
9
+ The AST can also simply itself, factoring out constant operations in some cases.
11
10
 
12
11
  == Examples
13
12
 
14
- @parser = Exalted::MathsParser.new
13
+ @parser = ExaltedMath::MathsParser.new
15
14
 
16
15
  # simple maths
17
- # The ast method results a two-tuple.
18
- # The first value is the success or failure of the parse
19
- # The second value is the AST, or failure message if it failed
16
+ # The parser returns the AST
17
+ # it raises a ParseFailedError in the case of error
20
18
  @parser.ast('3 + 4')
21
- #=> true, simple_ast
19
+ #=> simple_ast
22
20
 
23
21
  # symbolic values
24
22
  @parser.ast('Essence * 4')
25
- #=> true, symbolic_ast
23
+ #=> symbolic_ast
26
24
 
27
25
  # complex maths
28
26
  @parser.ast('(Essence * 4) + Willpower + highest[2](Compassion,Conviction,Temperance,Valor)')
29
- #=> true, complex_ast
27
+ #=> complex_ast
30
28
 
31
29
  # evaluate the Ast
32
- Exalted::Ast.value(simple_ast)
30
+ simple_ast.value
33
31
  #=> 7
34
32
 
35
33
  # evaluate a more complex Ast
36
- Exalted::Ast.value(symbolic_ast, {'essence' => 4})
34
+ symbolic_ast.value({'essence' => 4})
37
35
  #=> 16
38
36
 
39
37
  == Syntax
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
data/exalted_math.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "exalted_math"
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jonathan Stott"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exalted_math
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: