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 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.3.4'
8
+ gem.version = '0.3.5'
9
9
  gem.summary = 'Symbolic math for ruby'
10
10
  gem.description = <<TEXT
11
11
  Symbolic math for ruby.
@@ -46,7 +46,7 @@ module Symbolic
46
46
  end
47
47
 
48
48
  def inspect
49
- "Symbolic: #{to_s}"
49
+ "Symbolic(#{to_s})"
50
50
  end
51
51
 
52
52
  private
@@ -59,7 +59,7 @@ module Symbolic
59
59
  attr_reader :numeric, :symbolic
60
60
 
61
61
  def initialize(numeric, symbolic)
62
- @numeric, @symbolic = numeric, symbolic
62
+ @numeric, @symbolic = numeric.freeze, symbolic.freeze
63
63
  end
64
64
 
65
65
  def variables
@@ -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(variable, operation)
5
- @variable, @operation = variable, operation
7
+ def initialize(argument, operation)
8
+ @argument, @operation = argument, operation
6
9
  end
7
10
 
8
11
  def to_s
9
- "#{@operation}(#{@variable})"
12
+ "#{@operation}(#{@argument})"
10
13
  end
11
14
 
12
15
  def value
13
- ::Math.send @operation, @variable.value if undefined_variables.empty?
16
+ ::Math.send @operation, @argument.value if variables.any? {|it| it.value.nil? }
14
17
  end
15
18
 
16
19
  def variables
17
- @variable.variables
20
+ @argument.variables
18
21
  end
19
22
 
20
23
  def detailed_operations
21
- @variable.detailed_operations.tap {|it| it[@operation] += 1}
24
+ @argument.detailed_operations.tap {|it| it[@operation] += 1}
22
25
  end
23
26
  end
@@ -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
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-22 00:00:00 +03:00
12
+ date: 2009-12-30 00:00:00 +03:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency