nelson 0.5.0 → 0.6.0

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: 3fc4c34810d4cde8b5d8fc7228708acd891b3442
4
- data.tar.gz: 4fecf9537288391a76e32187c6de46d7e6c9daff
3
+ metadata.gz: 33aefff26477090c67b8f6cbecfaffd8ac3a3173
4
+ data.tar.gz: 1623ada73d5b8dcaea957cd320715cebcfd85d95
5
5
  SHA512:
6
- metadata.gz: d0510cb77e8a7876983137d7dc3609a3e50a767dc00820b22466dc468429e30d32d298929294af5f3dd72cb51fafd0b6bd8617e4b9d5a7b9a2bf6206092f86fc
7
- data.tar.gz: 9c76ba2a597640269f2add63dd51f45a712f59e4b37177e265c97487f874bd03b77e975afae2064f0cee288188df95d583a32ee8a6e89b13ef44072ea083557e
6
+ metadata.gz: ccb43e9f48aa59421075f7cd27462749a8665f335f5c836d28cbec331ddae08447363bb8f364dd1dc586bee1bc6e37ce5e73f2deff522f22fb5b69fae1acf044
7
+ data.tar.gz: aca694d340d8c234715a67b336f5d8f1c07238f7d4c1daabd60b96ddd116c104d6a58dd755ab5d47c48df12103a805e8196a21f7a34e2a99e75339cd754933ae
data/lib/nelson/dsl.rb CHANGED
@@ -1,8 +1,7 @@
1
1
 
2
2
  module Nelson
3
3
  module DSL
4
- module_function
5
-
4
+ extend self
6
5
  def product_of(*terms)
7
6
  MultipicationExpressionBuilder.new(*terms)
8
7
  end
@@ -28,6 +28,10 @@ module Nelson
28
28
  def divided_by(term)
29
29
  DivisionExpressionBuilder.new(self, term)
30
30
  end
31
+
32
+ def built_terms
33
+ terms.map { |e| e.is_a?(ExpressionBuilder) ? e.build : e }
34
+ end
31
35
  end
32
36
 
33
37
  autoload :MultipicationExpressionBuilder, "nelson/expression_builders/multipication_expression_builder"
@@ -2,8 +2,7 @@
2
2
  module Nelson
3
3
  class AdditionExpressionBuilder < ExpressionBuilder
4
4
  def build
5
- terms.map! { |e| e.is_a?(ExpressionBuilder) ? e.build : e }
6
- AdditionExpression.new(*terms)
5
+ AdditionExpression.new(*built_terms)
7
6
  end
8
7
  end
9
8
  end
@@ -4,10 +4,9 @@ module Nelson
4
4
  def initialize(term1, term2)
5
5
  super(term1, term2)
6
6
  end
7
-
7
+
8
8
  def build
9
- terms.map! { |e| e.is_a?(ExpressionBuilder) ? e.build : e }
10
- DivisionExpression.new(*terms)
9
+ DivisionExpression.new(*built_terms)
11
10
  end
12
11
  end
13
12
  end
@@ -2,8 +2,7 @@
2
2
  module Nelson
3
3
  class MultipicationExpressionBuilder < ExpressionBuilder
4
4
  def build
5
- terms.map! { |e| e.is_a?(ExpressionBuilder) ? e.build : e }
6
- MultipicationExpression.new(*terms)
5
+ MultipicationExpression.new(*built_terms)
7
6
  end
8
7
  end
9
8
  end
@@ -2,8 +2,7 @@
2
2
  module Nelson
3
3
  class SubtractionExpressionBuilder < ExpressionBuilder
4
4
  def build
5
- terms.map! { |e| e.is_a?(ExpressionBuilder) ? e.build : e }
6
- SubtractionExpression.new(*terms)
5
+ SubtractionExpression.new(*built_terms)
7
6
  end
8
7
  end
9
8
  end
@@ -2,11 +2,11 @@
2
2
  module Nelson
3
3
  class DivisionExpression < Expression
4
4
  def initialize(term1, term2)
5
- super(term1.to_f, term2.to_f)
5
+ super(term1, term2)
6
6
  end
7
7
 
8
8
  def call
9
- terms.reduce(:/)
9
+ terms.map { |n| n.is_a?(Numeric) ? n.to_f : n }.reduce(:/)
10
10
  end
11
11
 
12
12
  def to_s
@@ -1,3 +1,3 @@
1
1
  module Nelson
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nelson
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Metcalfe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-29 00:00:00.000000000 Z
11
+ date: 2015-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler