eqn 1.4.1 → 1.4.2

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: 15427350b2000655804633ff9ff5726c2f7a958b
4
- data.tar.gz: f2a1cd9cce250a52ab4c1fa4dae75ddf0da118ad
3
+ metadata.gz: b233964ecca218e4954b73f14bf5012cf0c7d30d
4
+ data.tar.gz: 831f81cb25eefc402de5219089f4403eb1004c1d
5
5
  SHA512:
6
- metadata.gz: bc0e5afed9c04afcf453247fd648f8ddd902a03f3dc9605d911604512057e9c30b3049e571100743f6624d6cf07c038a3165b3fa1627fabcf579652607816195
7
- data.tar.gz: 8750c30884c3c5e09f3a13cd69dfa6b39a82b7581bf935a14ee4db35d6da208b0b66686d1ec5d13af781ee587ff7d71af36963b470f423ae29180e500f67b46d
6
+ metadata.gz: 7bbf42e68e90df5969c8bfc238c6b59f289a323dfc30ba2705b86271ca77cf87ae25880b5cf3bb41f13b4e8af302c6541e04caa77a6920f762e0b3a64fb844dc
7
+ data.tar.gz: dae0c84242de38d1c880f6c629568c3b11a05351fb37cefaa316287a9a7f7123166a8107f7f83e3e9d54b4a278b63c6ac4ea35279c0b171525b0eab79f51ce42
data/README.md CHANGED
@@ -66,11 +66,18 @@ 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
69
+
70
+ On calculator instances, variables can be set via key-value syntax, hash syntax, or as a method:
71
+
72
+ $ calc = Eqn::Calculator.new('1 + abc')
73
+ $ calc.set(:abc, 3.0)
74
+ $ calc.abc
75
+ # => 3.0
76
+ $ calc.set(abc: 4.0)
77
+ $ calc.abc
71
78
  # => 4.0
72
- $ calc_two.set(abc: 4.0)
73
- $ calc_two.calc
79
+ $ calc.abc = 5.0
80
+ $ calc.abc
74
81
  # => 5.0
75
82
 
76
83
  ### Functions
@@ -13,9 +13,16 @@ module Eqn
13
13
  end
14
14
  end
15
15
 
16
- def method_missing(method)
17
- super unless %i(calculate calc valid?).include?(method)
18
- self.class.send(method, @eqn, @vars)
16
+ def method_missing(method, *args)
17
+ if %i(calculate calc valid?).include?(method)
18
+ self.class.send(method, @eqn, @vars)
19
+ elsif (match = method.to_s.match(/^[A-Za-z]+=$/))
20
+ @vars[match.to_s.delete('=').intern] = args.first
21
+ elsif (var = method.to_s.match(/^[A-Za-z]+$/).to_s.intern) && @vars.key?(var)
22
+ @vars[var]
23
+ else
24
+ super
25
+ end
19
26
  end
20
27
 
21
28
  class << self
@@ -1,3 +1,3 @@
1
1
  module Eqn
2
- VERSION = '1.4.1'.freeze
2
+ VERSION = '1.4.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eqn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Schneider
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-27 00:00:00.000000000 Z
11
+ date: 2016-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: treetop