symbolic 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/extensions/kernel.rb +2 -2
- data/lib/symbolic/variable.rb +9 -3
- metadata +1 -1
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ begin
|
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "symbolic"
|
8
|
-
gem.version = '0.1.
|
8
|
+
gem.version = '0.1.5'
|
9
9
|
gem.summary = 'Symbolic math for ruby'
|
10
10
|
gem.description = %Q{Symbolic math can be really helpful if you want to simplify some giant equation or if you don't want to get a performance hit re-evaluating big math expressions every time when few variables change.}
|
11
11
|
gem.email = "ravwar@gmail.com"
|
data/lib/extensions/kernel.rb
CHANGED
data/lib/symbolic/variable.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
module Symbolic
|
2
2
|
class Variable < Operatable
|
3
|
-
attr_accessor :
|
3
|
+
attr_accessor :name, :proc
|
4
|
+
attr_writer :value
|
4
5
|
|
5
|
-
def initialize(options)
|
6
|
+
def initialize(options={}, &proc)
|
6
7
|
@name, @value = options.values_at(:name, :value)
|
8
|
+
@proc = proc
|
9
|
+
end
|
10
|
+
|
11
|
+
def value
|
12
|
+
@value || @proc && @proc.call
|
7
13
|
end
|
8
14
|
|
9
15
|
def to_s
|
@@ -11,7 +17,7 @@ module Symbolic
|
|
11
17
|
end
|
12
18
|
|
13
19
|
def undefined_variables
|
14
|
-
|
20
|
+
value ? [] : [self]
|
15
21
|
end
|
16
22
|
end
|
17
23
|
end
|