ChebyRuby 0.0.3.pre → 0.1.0
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 +4 -4
- data/Rakefile +15 -0
- data/lib/chebyruby/expression.rb +5 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3252d81142e31e2eb4e1f6f9375505e82ab92351
|
4
|
+
data.tar.gz: c24e5191aff126747b837a13e5a8fc9bb0dbf79e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5919c55140a5632c3defee1f22c1459ef524d6351e4f54b1aa8598bf2ba5fbb7262bb1f7cf1febe3a0db1168bbfda9b59e482d7412e410cd4b35972910ed7791
|
7
|
+
data.tar.gz: e57d75af7a75e6421707b8cd6226368c12fb6cabc642fff624b831738712ed7f44ab653c90fe877c2b74b2f275224429240258bba6c85ec24fa2d452003e2b92
|
data/Rakefile
CHANGED
@@ -4,5 +4,20 @@ Rake::TestTask.new do |t|
|
|
4
4
|
t.libs << 'test'
|
5
5
|
end
|
6
6
|
|
7
|
+
|
7
8
|
desc 'Run tests'
|
8
9
|
task default: :test
|
10
|
+
|
11
|
+
task :clean do
|
12
|
+
`rm *.gem`
|
13
|
+
end
|
14
|
+
|
15
|
+
task :build do
|
16
|
+
`gem build chebyruby.gemspec`
|
17
|
+
end
|
18
|
+
|
19
|
+
task :deploy do
|
20
|
+
`rake clean`
|
21
|
+
`rake build`
|
22
|
+
`gem push *.gem`
|
23
|
+
end
|
data/lib/chebyruby/expression.rb
CHANGED
@@ -17,7 +17,7 @@ class Expression
|
|
17
17
|
a = []
|
18
18
|
nested?[:left] ? a << left.vars : a << left.x
|
19
19
|
nested?[:right] ? a << right.vars : a << right.x
|
20
|
-
a.flatten
|
20
|
+
(a.flatten rescue a).select{|i| String === i}.uniq
|
21
21
|
end
|
22
22
|
|
23
23
|
def nested?
|
@@ -39,5 +39,9 @@ class Expression
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def to_func
|
42
|
+
if a.vars.size == 1
|
43
|
+
blk = ->(intvar) {eval(to_s.gsub(vars[0],'intvar'))}
|
44
|
+
UnivariateFunction.new(&blk)
|
45
|
+
end
|
42
46
|
end
|
43
47
|
end
|