eqn 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66e4ae8e6dc085c3b899b571fce70d14c5cf7b75
4
- data.tar.gz: c42d2d4fd3d8f705e8f22b25cee68cf8ef57f472
3
+ metadata.gz: 08c722b548df16e9f686ca109df362c10592c8a0
4
+ data.tar.gz: aedb663d5c308aaf018bab79028432e0538883be
5
5
  SHA512:
6
- metadata.gz: 94d074d217a93397af2d48c0beec74f4b24db070a730100e47fad5c3470449bd441a0294a51f4ee26d7766c4b991b37c95cd0fae6b01a56564729dd51f936c46
7
- data.tar.gz: f70fc70d36c8dbf3706c664122d24483a21f8e3c04bd4be5ce1cca39740f359cf1c33c2a989df6e12cfc1a18cfd10d2d3bbcf81d829329c125af9b27a457156e
6
+ metadata.gz: f8c56e988905d9860e879241e9ce231db2d1ba82a68e38a317d09b575ecc9a53e228288b88e1b0a448ff4bb5cfeac1b4c6bc429e7e4b730d9600f5c564d2a90b
7
+ data.tar.gz: 24b4da1f8663c8cbb6c12246ecbe82eb78a477ab093370c81a37605492b50a0b783fe13df6ca3a892de65fb016ae2ad56ca4a8eeeeb8b4ccaaee9861582f8a6d
data/README.md CHANGED
@@ -75,6 +75,10 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
75
75
 
76
76
  The gem uses rspec for testing; run `rspec` from the application root to execute the tests.
77
77
 
78
+ ## Authorship
79
+
80
+ Written by Zach Schneider for [Aha!, the world's #1 product roadmap software](http://www.aha.io/)
81
+
78
82
  ## Contributing
79
83
 
80
84
  1. Fork it ( https://github.com/schneidmaster/eqn/fork )
@@ -64,7 +64,11 @@ grammar Eqn
64
64
  end
65
65
 
66
66
  rule signed_float
67
- sign? space? digits? decimal? <Eqn::Number::SignedNumber>
67
+ sign? space? (float / digits) <Eqn::Number::SignedNumber>
68
+ end
69
+
70
+ rule float
71
+ digits? decimal <Eqn::Number::Float>
68
72
  end
69
73
 
70
74
  rule decimal
@@ -99,6 +103,10 @@ grammar Eqn
99
103
  / '!=' <Eqn::Terminal::CompOp::Neq>
100
104
  end
101
105
 
106
+ rule dot
107
+ '.' <Eqn::Terminal::Dot>
108
+ end
109
+
102
110
  rule exp
103
111
  'e' / 'E'
104
112
  end
@@ -3,7 +3,7 @@ module Eqn
3
3
  class << self
4
4
  def calc(data)
5
5
  result = Parser.parse(data).value
6
- fail ZeroDivisionError if result.is_a?(Float) && result.abs == Float::INFINITY
6
+ fail ZeroDivisionError if result.is_a?(Float) && (result.abs == Float::INFINITY || result.nan?)
7
7
  result
8
8
  end
9
9
 
@@ -9,27 +9,34 @@ module Eqn
9
9
  base
10
10
  end
11
11
 
12
- # rubocop:disable Metrics/AbcSize
13
12
  class SignedNumber < Node
14
13
  def value
15
14
  # Store sign if any.
16
15
  sign_negative = elements.shift.negative? if elements.first.is_a? Terminal::Sign
17
16
 
18
- # Store base number.
19
- base = elements.shift.value
20
-
21
- # Handle decimal.
22
- base += elements.shift.value unless elements.empty?
17
+ # Evaluate float.
18
+ value = elements.shift.value
23
19
 
24
20
  # Apply sign if any.
25
21
  if sign_negative
26
- -base
22
+ -value
27
23
  else
28
- base
24
+ value
29
25
  end
30
26
  end
31
27
  end
32
28
 
29
+ class Float < Node
30
+ def value
31
+ base = elements.shift.value
32
+
33
+ # Add any decimal.
34
+ base += elements.shift.value unless elements.empty?
35
+
36
+ base
37
+ end
38
+ end
39
+
33
40
  class Decimal < Node
34
41
  def value
35
42
  elements.shift.dec_value
@@ -1,3 +1,3 @@
1
1
  module Eqn
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eqn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Schneider