eqn 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.rubocop.yml +18 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +82 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +5 -0
- data/eqn.gemspec +28 -0
- data/lib/eqn.rb +5 -0
- data/lib/eqn.treetop +113 -0
- data/lib/eqn/calculator.rb +16 -0
- data/lib/eqn/comparation.rb +21 -0
- data/lib/eqn/engine.rb +7 -0
- data/lib/eqn/expression.rb +21 -0
- data/lib/eqn/function.rb +37 -0
- data/lib/eqn/number.rb +44 -0
- data/lib/eqn/parser.rb +42 -0
- data/lib/eqn/terminal.rb +91 -0
- data/lib/eqn/version.rb +3 -0
- metadata +136 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5169b7bc9b7ffba3e28eae977ec4ec934a56ae22
|
4
|
+
data.tar.gz: 320adbd2103e2303abafa6a04bc3ac3956904e92
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 43290301b723b40ef8f834038b612c0c382a20bbc835210fa3be6d510afbf20039e78eaf9de2405c9a80ec9326ce15782b7530602b2b4d702f5a3e5043946a87
|
7
|
+
data.tar.gz: 6b9a586c947a93085d89d0f21d0a040d996a9b2611ef06a07e2751755452220aebab7a4915a4fcd3cf8e258e05af6a82ac083bf35cec00f62c7f3ceca28c9418
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- db/**/*
|
4
|
+
|
5
|
+
BlockNesting:
|
6
|
+
Max: 4
|
7
|
+
ClassLength:
|
8
|
+
Enabled: False
|
9
|
+
ClassVars:
|
10
|
+
Enabled: False
|
11
|
+
CyclomaticComplexity:
|
12
|
+
Enabled: False
|
13
|
+
Documentation:
|
14
|
+
Enabled: false
|
15
|
+
LineLength:
|
16
|
+
Max: 175
|
17
|
+
MethodLength:
|
18
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Aha! Labs Inc
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# Eqn
|
2
|
+
|
3
|
+
Eqn uses the Treetop parser generator to safely evaluate mathematical expressions in Ruby.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'eqn'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install eqn
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
To evaluate an equation string, run the following:
|
24
|
+
|
25
|
+
$ Eqn::Calculator.calc('1 + 1')
|
26
|
+
# => 2
|
27
|
+
|
28
|
+
You can also check if an equation is valid:
|
29
|
+
|
30
|
+
$ Eqn::Calculator.valid?('1 + 1')
|
31
|
+
# => true
|
32
|
+
$ Eqn::Calculator.valid?('1 + + 1')
|
33
|
+
# => false
|
34
|
+
|
35
|
+
If you want to peek at how Eqn is parsing an equation, run the following to get the syntax tree:
|
36
|
+
|
37
|
+
$ Eqn::Parser.parse('1 + 1')
|
38
|
+
# => <syntax tree is printed>
|
39
|
+
|
40
|
+
Eqn follows the standard mathematical order of operations: parentheses, exponentiation, multiplication/division, addition/subtraction. It ignores whitespace, so `1 + 1` === `1+1`. (However, it does not ignore whitespace between two numbers, so `1 1` is invalid.)
|
41
|
+
|
42
|
+
### Functions
|
43
|
+
|
44
|
+
Eqn presently supports four functions:
|
45
|
+
|
46
|
+
**if**
|
47
|
+
|
48
|
+
Syntax: `if(comparison, value_if_true, value_if_false)`
|
49
|
+
|
50
|
+
For example, `if(5 > 3, 1, 2)` would evaluate to `1`.
|
51
|
+
|
52
|
+
**round**
|
53
|
+
|
54
|
+
Syntax: `round(number)`
|
55
|
+
|
56
|
+
Rounds the number up if the decimal is greater than 0.5 and down otherwise (i.e. "normal" rounding).
|
57
|
+
|
58
|
+
**roundup**
|
59
|
+
|
60
|
+
Syntax: `roundup(number)`
|
61
|
+
|
62
|
+
Rounds the number up to the next whole integer (i.e. ceiling function)
|
63
|
+
|
64
|
+
**rounddown**
|
65
|
+
|
66
|
+
Syntax: `rounddown(number)`
|
67
|
+
|
68
|
+
Rounds the number down to the next whole integer (i.e. floor function)
|
69
|
+
|
70
|
+
## Development
|
71
|
+
|
72
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
73
|
+
|
74
|
+
The gem uses rspec for testing; run `rspec` from the application root to execute the tests.
|
75
|
+
|
76
|
+
## Contributing
|
77
|
+
|
78
|
+
1. Fork it ( https://github.com/schneidmaster/eqn/fork )
|
79
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
80
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
81
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
82
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'eqn'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/eqn.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'eqn/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'eqn'
|
8
|
+
spec.version = Eqn::VERSION
|
9
|
+
spec.authors = ['Zach Schneider']
|
10
|
+
spec.email = ['zach@aha.io']
|
11
|
+
|
12
|
+
spec.summary = 'A gem to evaluate numerical equations.'
|
13
|
+
spec.description = 'A gem to evaluate numerical equations. Includes support for functions.'
|
14
|
+
spec.homepage = 'https://github.com/schneidmaster/eqn'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_dependency 'treetop', '~> 1.4.14'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.8'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'rubocop', '~> 0.31'
|
27
|
+
spec.add_development_dependency 'byebug'
|
28
|
+
end
|
data/lib/eqn.rb
ADDED
data/lib/eqn.treetop
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
grammar Eqn
|
2
|
+
rule comparation
|
3
|
+
expression comp_group? <Eqn::Comparation>
|
4
|
+
end
|
5
|
+
|
6
|
+
rule comp_group
|
7
|
+
comp_op expression <Eqn::Comparation::CompGroup>
|
8
|
+
end
|
9
|
+
|
10
|
+
rule expression
|
11
|
+
multitive addsub_group? <Eqn::Expression>
|
12
|
+
end
|
13
|
+
|
14
|
+
rule addsub_group
|
15
|
+
addsub_op expression <Eqn::Expression::ExprGroup>
|
16
|
+
end
|
17
|
+
|
18
|
+
rule multitive
|
19
|
+
exponentiative muldiv_group? <Eqn::Expression>
|
20
|
+
end
|
21
|
+
|
22
|
+
rule muldiv_group
|
23
|
+
muldiv_op multitive <Eqn::Expression::ExprGroup>
|
24
|
+
end
|
25
|
+
|
26
|
+
rule exponentiative
|
27
|
+
operand pow_group? <Eqn::Expression>
|
28
|
+
end
|
29
|
+
|
30
|
+
rule pow_group
|
31
|
+
pow_op exponentiative <Eqn::Expression::ExprGroup>
|
32
|
+
end
|
33
|
+
|
34
|
+
rule operand
|
35
|
+
function / group / number
|
36
|
+
end
|
37
|
+
|
38
|
+
rule function
|
39
|
+
if_func / round_func / roundup_func / rounddown_func
|
40
|
+
end
|
41
|
+
|
42
|
+
rule if_func
|
43
|
+
'if' '(' comparation ',' expression ',' expression ')' <Eqn::Function::If>
|
44
|
+
end
|
45
|
+
|
46
|
+
rule round_func
|
47
|
+
'round' group <Eqn::Function::Round>
|
48
|
+
end
|
49
|
+
|
50
|
+
rule roundup_func
|
51
|
+
'roundup' group <Eqn::Function::RoundUp>
|
52
|
+
end
|
53
|
+
|
54
|
+
rule rounddown_func
|
55
|
+
'rounddown' group <Eqn::Function::RoundDown>
|
56
|
+
end
|
57
|
+
|
58
|
+
rule group
|
59
|
+
'(' expression ')' <Eqn::Expression>
|
60
|
+
end
|
61
|
+
|
62
|
+
rule number
|
63
|
+
signed_float exponent? <Eqn::Number>
|
64
|
+
end
|
65
|
+
|
66
|
+
rule signed_float
|
67
|
+
sign? digits decimal? <Eqn::Number::SignedNumber>
|
68
|
+
end
|
69
|
+
|
70
|
+
rule decimal
|
71
|
+
'.' digits <Eqn::Number::Decimal>
|
72
|
+
end
|
73
|
+
|
74
|
+
rule exponent
|
75
|
+
exp signed_float <Eqn::Number::Exponent>
|
76
|
+
end
|
77
|
+
|
78
|
+
rule pow_op
|
79
|
+
'^' <Eqn::Terminal::Op::Pow>
|
80
|
+
end
|
81
|
+
|
82
|
+
rule muldiv_op
|
83
|
+
'*' <Eqn::Terminal::Op::Mul>
|
84
|
+
/ '/' <Eqn::Terminal::Op::Div>
|
85
|
+
end
|
86
|
+
|
87
|
+
rule addsub_op
|
88
|
+
'+' <Eqn::Terminal::Op::Add>
|
89
|
+
/ '-' <Eqn::Terminal::Op::Sub>
|
90
|
+
end
|
91
|
+
|
92
|
+
rule comp_op
|
93
|
+
'<=' <Eqn::Terminal::CompOp::Lte>
|
94
|
+
/ '>=' <Eqn::Terminal::CompOp::Gte>
|
95
|
+
/ '<' <Eqn::Terminal::CompOp::Lt>
|
96
|
+
/ '>' <Eqn::Terminal::CompOp::Gt>
|
97
|
+
/ '==' <Eqn::Terminal::CompOp::Eq>
|
98
|
+
/ '=' <Eqn::Terminal::CompOp::Eq>
|
99
|
+
/ '!=' <Eqn::Terminal::CompOp::Neq>
|
100
|
+
end
|
101
|
+
|
102
|
+
rule exp
|
103
|
+
'e' / 'E'
|
104
|
+
end
|
105
|
+
|
106
|
+
rule sign
|
107
|
+
'+' / '-' <Eqn::Terminal::Sign>
|
108
|
+
end
|
109
|
+
|
110
|
+
rule digits
|
111
|
+
[0-9]+ <Eqn::Terminal::Digits>
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Eqn
|
2
|
+
class Node < Treetop::Runtime::SyntaxNode; end
|
3
|
+
|
4
|
+
class Comparation < Node
|
5
|
+
def value
|
6
|
+
val_one = elements.shift.value
|
7
|
+
if elements.empty?
|
8
|
+
val_one
|
9
|
+
else
|
10
|
+
op, val_two = elements.shift.value
|
11
|
+
val_one.send(op, val_two)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class CompGroup < Node
|
16
|
+
def value
|
17
|
+
[elements.shift.value, elements.shift.value]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/eqn/engine.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Eqn
|
2
|
+
class Node < Treetop::Runtime::SyntaxNode; end
|
3
|
+
|
4
|
+
class Expression < Node
|
5
|
+
def value
|
6
|
+
if elements.count == 1
|
7
|
+
elements.shift.value
|
8
|
+
else
|
9
|
+
base = elements.shift.value
|
10
|
+
op, num = elements.shift.value
|
11
|
+
base.send(op, num)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class ExprGroup < Node
|
16
|
+
def value
|
17
|
+
[elements.shift.value, elements.shift.value]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/eqn/function.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module Eqn
|
2
|
+
class Node < Treetop::Runtime::SyntaxNode; end
|
3
|
+
|
4
|
+
module Function
|
5
|
+
class If < Node
|
6
|
+
def value
|
7
|
+
comp_val = elements.shift.value
|
8
|
+
ls = elements.shift.value
|
9
|
+
rs = elements.shift.value
|
10
|
+
|
11
|
+
if comp_val
|
12
|
+
ls
|
13
|
+
else
|
14
|
+
rs
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Round < Node
|
20
|
+
def value
|
21
|
+
elements.shift.value.round
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class RoundUp < Node
|
26
|
+
def value
|
27
|
+
elements.shift.value.ceil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class RoundDown < Node
|
32
|
+
def value
|
33
|
+
elements.shift.value.floor
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/eqn/number.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
module Eqn
|
2
|
+
class Node < Treetop::Runtime::SyntaxNode; end
|
3
|
+
|
4
|
+
class Number < Node
|
5
|
+
def value
|
6
|
+
base = elements.shift.value
|
7
|
+
# Apply any exponent.
|
8
|
+
base *= elements.shift.value unless elements.empty?
|
9
|
+
base
|
10
|
+
end
|
11
|
+
|
12
|
+
class SignedNumber < Node
|
13
|
+
def value
|
14
|
+
# Store sign if any.
|
15
|
+
sign_negative = elements.shift.negative? if elements.first.is_a? Terminal::Sign
|
16
|
+
|
17
|
+
# Store base number.
|
18
|
+
base = elements.shift.value
|
19
|
+
|
20
|
+
# Handle decimal.
|
21
|
+
base += elements.shift.value unless elements.empty?
|
22
|
+
|
23
|
+
# Apply sign if any.
|
24
|
+
if sign_negative
|
25
|
+
-base
|
26
|
+
else
|
27
|
+
base
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class Decimal < Node
|
33
|
+
def value
|
34
|
+
elements.shift.dec_value
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class Exponent < Node
|
39
|
+
def value
|
40
|
+
10**elements.shift.value
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/eqn/parser.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'eqn/function'
|
2
|
+
require 'eqn/comparation'
|
3
|
+
require 'eqn/expression'
|
4
|
+
require 'eqn/number'
|
5
|
+
require 'eqn/terminal'
|
6
|
+
|
7
|
+
module Eqn
|
8
|
+
WHITESPACE_REGEX = /([^0-9]( )+[^0-9])|([^0-9]( )+[0-9])|([0-9]( )+[^0-9])/
|
9
|
+
|
10
|
+
class Parser
|
11
|
+
# Load the Treetop grammar from the grammar.
|
12
|
+
Treetop.load(File.join(File.dirname(__dir__), 'eqn.treetop'))
|
13
|
+
@@parser = EqnParser.new
|
14
|
+
|
15
|
+
def self.parse(data)
|
16
|
+
# Remove any whitespace and pass the data over to the parser instance.
|
17
|
+
data.downcase!
|
18
|
+
while data =~ Eqn::WHITESPACE_REGEX do
|
19
|
+
data = data.downcase.gsub(Eqn::WHITESPACE_REGEX) do
|
20
|
+
Regexp.last_match.to_s.delete(' ')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
tree = @@parser.parse(data)
|
24
|
+
|
25
|
+
# Raise any errors.
|
26
|
+
if tree.nil?
|
27
|
+
fail Exception, "Parse error at offset: #{@@parser.index}" + @@parser.failure_reason
|
28
|
+
end
|
29
|
+
|
30
|
+
# Remove extraneous nodes and return the tree.
|
31
|
+
clean_tree(tree)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.clean_tree(root_node)
|
35
|
+
return if root_node.elements.nil?
|
36
|
+
root_node.elements.delete_if { |node| node.class.name == 'Treetop::Runtime::SyntaxNode' }
|
37
|
+
root_node.elements.each { |node| clean_tree(node) }
|
38
|
+
root_node
|
39
|
+
end
|
40
|
+
private_class_method :clean_tree
|
41
|
+
end
|
42
|
+
end
|
data/lib/eqn/terminal.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
module Eqn
|
2
|
+
module Terminal
|
3
|
+
class Node < Treetop::Runtime::SyntaxNode; end
|
4
|
+
|
5
|
+
class Digits < Node
|
6
|
+
def dec_value
|
7
|
+
".#{text_value}".to_f
|
8
|
+
end
|
9
|
+
|
10
|
+
def value
|
11
|
+
text_value.to_f
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Sign < Node
|
16
|
+
def negative?
|
17
|
+
text_value == '-'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Op < Node
|
22
|
+
class Add < Node
|
23
|
+
def value
|
24
|
+
'+'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Sub < Node
|
29
|
+
def value
|
30
|
+
'-'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class Mul < Node
|
35
|
+
def value
|
36
|
+
'*'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class Div < Node
|
41
|
+
def value
|
42
|
+
'/'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class Pow < Node
|
47
|
+
def value
|
48
|
+
'**'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class CompOp < Node
|
54
|
+
class Lt < Node
|
55
|
+
def value
|
56
|
+
'<'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class Gt < Node
|
61
|
+
def value
|
62
|
+
'>'
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
class Lte < Node
|
67
|
+
def value
|
68
|
+
'<='
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
class Gte < Node
|
73
|
+
def value
|
74
|
+
'>='
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class Eq < Node
|
79
|
+
def value
|
80
|
+
'=='
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
class Neq < Node
|
85
|
+
def value
|
86
|
+
'!='
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
data/lib/eqn/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eqn
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zach Schneider
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: treetop
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.4.14
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.4.14
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.31'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.31'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: byebug
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: A gem to evaluate numerical equations. Includes support for functions.
|
84
|
+
email:
|
85
|
+
- zach@aha.io
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".rubocop.yml"
|
93
|
+
- ".travis.yml"
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- bin/console
|
99
|
+
- bin/setup
|
100
|
+
- eqn.gemspec
|
101
|
+
- lib/eqn.rb
|
102
|
+
- lib/eqn.treetop
|
103
|
+
- lib/eqn/calculator.rb
|
104
|
+
- lib/eqn/comparation.rb
|
105
|
+
- lib/eqn/engine.rb
|
106
|
+
- lib/eqn/expression.rb
|
107
|
+
- lib/eqn/function.rb
|
108
|
+
- lib/eqn/number.rb
|
109
|
+
- lib/eqn/parser.rb
|
110
|
+
- lib/eqn/terminal.rb
|
111
|
+
- lib/eqn/version.rb
|
112
|
+
homepage: https://github.com/schneidmaster/eqn
|
113
|
+
licenses:
|
114
|
+
- MIT
|
115
|
+
metadata: {}
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
requirements: []
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 2.4.6
|
133
|
+
signing_key:
|
134
|
+
specification_version: 4
|
135
|
+
summary: A gem to evaluate numerical equations.
|
136
|
+
test_files: []
|