symbolic 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/symbolic.rb +1 -1
- data/lib/symbolic/expression.rb +1 -1
- data/lib/symbolic/function.rb +9 -6
- data/lib/symbolic/math.rb +4 -1
- metadata +2 -2
data/Rakefile
CHANGED
data/lib/symbolic.rb
CHANGED
data/lib/symbolic/expression.rb
CHANGED
data/lib/symbolic/function.rb
CHANGED
@@ -1,23 +1,26 @@
|
|
1
1
|
class Symbolic::Function
|
2
|
+
=begin
|
3
|
+
This class is proxy for methods from Math module.
|
4
|
+
=end
|
2
5
|
include Symbolic
|
3
6
|
|
4
|
-
def initialize(
|
5
|
-
@
|
7
|
+
def initialize(argument, operation)
|
8
|
+
@argument, @operation = argument, operation
|
6
9
|
end
|
7
10
|
|
8
11
|
def to_s
|
9
|
-
"#{@operation}(#{@
|
12
|
+
"#{@operation}(#{@argument})"
|
10
13
|
end
|
11
14
|
|
12
15
|
def value
|
13
|
-
::Math.send @operation, @
|
16
|
+
::Math.send @operation, @argument.value if variables.any? {|it| it.value.nil? }
|
14
17
|
end
|
15
18
|
|
16
19
|
def variables
|
17
|
-
@
|
20
|
+
@argument.variables
|
18
21
|
end
|
19
22
|
|
20
23
|
def detailed_operations
|
21
|
-
@
|
24
|
+
@argument.detailed_operations.tap {|it| it[@operation] += 1}
|
22
25
|
end
|
23
26
|
end
|
data/lib/symbolic/math.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
module Symbolic::Math
|
2
|
+
=begin
|
3
|
+
This module is a reflection for Math module which allows to use symbolic expressions as parameters for its methods.
|
4
|
+
=end
|
2
5
|
Math.methods(false).each do |method|
|
3
|
-
instance_eval <<-CODE, __FILE__, __LINE__
|
6
|
+
instance_eval <<-CODE, __FILE__, __LINE__ + 1
|
4
7
|
def #{method}(argument)
|
5
8
|
unless argument.is_a? Numeric
|
6
9
|
Symbolic::Function.new argument, :#{method}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: symbolic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- brainopia
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-30 00:00:00 +03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|