eqn 1.4.0 → 1.4.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: d070fa9a192c3c584f4d91b4adb0b8e7500f8cb5
4
- data.tar.gz: a88cd4517b3978cae22afc0efa8e57cd4ad57d9b
3
+ metadata.gz: 15427350b2000655804633ff9ff5726c2f7a958b
4
+ data.tar.gz: f2a1cd9cce250a52ab4c1fa4dae75ddf0da118ad
5
5
  SHA512:
6
- metadata.gz: 98a4e10833eef688a1ade5d4eb2ebde63df3555c6305216c8e5aa58904656b0b2a21639c91bad1a298b3dce0f13a4017db68eff7bc3c0fa6b1b12e9d89e44a04
7
- data.tar.gz: cf9c913e5e3229ce7258e9babf4d1e40dc807d4c5dc4e0ee3dcf78ebea3fcbe328e8adcff6dddbbfd3b9022586e0374f102893983d027245f98d9a85556eb52f
6
+ metadata.gz: bc0e5afed9c04afcf453247fd648f8ddd902a03f3dc9605d911604512057e9c30b3049e571100743f6624d6cf07c038a3165b3fa1627fabcf579652607816195
7
+ data.tar.gz: 8750c30884c3c5e09f3a13cd69dfa6b39a82b7581bf935a14ee4db35d6da208b0b66686d1ec5d13af781ee587ff7d71af36963b470f423ae29180e500f67b46d
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.3.0
data/README.md CHANGED
@@ -66,6 +66,12 @@ If you need distinct equations with variable sets, you can instantiate separate
66
66
  $ calc_two = Eqn::Calculator.new('1 + abc', abc: 5.0)
67
67
  $ calc_two.calc
68
68
  # => 6.0
69
+ $ calc_two.set(:abc, 3.0)
70
+ $ calc_two.calc
71
+ # => 4.0
72
+ $ calc_two.set(abc: 4.0)
73
+ $ calc_two.calc
74
+ # => 5.0
69
75
 
70
76
  ### Functions
71
77
 
@@ -5,8 +5,12 @@ module Eqn
5
5
  @vars = vars
6
6
  end
7
7
 
8
- def set(key, value)
9
- @vars[key.intern] = value
8
+ def set(key_or_hash, value = nil)
9
+ if key_or_hash.is_a?(Hash)
10
+ @vars.merge!(key_or_hash)
11
+ else
12
+ @vars[key_or_hash.intern] = value
13
+ end
10
14
  end
11
15
 
12
16
  def method_missing(method)
@@ -16,14 +20,13 @@ module Eqn
16
20
 
17
21
  class << self
18
22
  def calculate(data, vars = {})
19
- @@cache_vars = @@vars if defined?(@@vars)
20
23
  @@vars = vars
21
24
  begin
22
25
  result = Parser.parse(data).value
23
26
  raise ZeroDivisionError if result.is_a?(Float) && (result.abs == Float::INFINITY || result.nan?)
24
27
  result
25
28
  ensure
26
- @@vars = defined?(@@cache_vars) ? @@cache_vars : nil
29
+ @@vars = nil
27
30
  end
28
31
  end
29
32
  alias calc calculate
data/lib/eqn/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eqn
2
- VERSION = '1.4.0'.freeze
2
+ VERSION = '1.4.1'.freeze
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.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Schneider