danica 2.0.0 → 2.0.1

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: 0cbd63065be86cd93d10bf1a1d2fc624775e3331
4
- data.tar.gz: bf977f09ed4bdb576aad2a2683fd6758a017a2d1
3
+ metadata.gz: 8dee90fae6e225d80aa3ad1372b595e9ddb1838e
4
+ data.tar.gz: 4c48eb2ad5b03f32a548728b6753e72e0495ba9c
5
5
  SHA512:
6
- metadata.gz: 43d21db5bc46b37c41fda6a23f8fbeee6e147b1c55eb256e31951175a7bab6d75770b8f2c9feeb335f15da068647cb5409a5b64d1076d40cf16df7e30cc6f33c
7
- data.tar.gz: e3aff36c623f3a9548c643985faf82e94a13e1bc2f2a0630cfa47dce5c41abd0805ec01414f2bad43fa5df91ff3799bec16cfc478f03c469ef9aae50f77d761e
6
+ metadata.gz: 592db252b53a3a6a40288c12756338d5c94aedaff3a574e896ed2a011c6ea65d311d0b2786bbcfca00b9f4997be7f073e72981413805336fa92c5a3876c68cca
7
+ data.tar.gz: 669d72083cf2e11b9abaad19872e8d02c0cc31badea6a1612252bb0b18db64d2e416bda11fda10f9d66e4e97108f42ab490df3ee5c60d9cdc49ce633a0cb3ec7
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danica (2.0.0)
4
+ danica (2.0.1)
5
5
  activemodel
6
6
  activesupport
7
7
  bidu-core_ext
data/README.md CHANGED
@@ -22,7 +22,7 @@ Operators are much like function, but they do not have a name.
22
22
 
23
23
  While a function would be something in the format ```f(x) = x + 1```, an operator would just represent the sum ```x + 1```
24
24
 
25
- Operators are to be composed to create a Function (see below) being their difference almost semantic
25
+ Operators are to be composed to create a Function ([see below](#functions)) being their difference almost semantic
26
26
 
27
27
  ```ruby
28
28
  class MyOperator < Danica::Operator
@@ -191,7 +191,7 @@ returns
191
191
  S0 + V0 * t + a * t**2/2
192
192
  ```
193
193
 
194
- ##### to_gnu
194
+ ##### calculate / to_f
195
195
  ```ruby
196
196
  fx = Danica::Function::Spatial.new(
197
197
  time: :t,
@@ -7,5 +7,6 @@ module Danica
7
7
  require 'danica/operator'
8
8
  require 'danica/function'
9
9
  require 'danica/exception'
10
+ require 'danica/constant'
10
11
  end
11
12
 
@@ -0,0 +1,35 @@
1
+ module Danica
2
+ class Constant
3
+ attr_reader :value, :latex, :gnu
4
+
5
+ def initialize(value, latex, gnu)
6
+ @value = value
7
+ @latex = latex
8
+ @gnu = gnu
9
+ end
10
+
11
+ def to_f
12
+ value.to_f
13
+ end
14
+
15
+ def ==(other)
16
+ return false unless other.class == self.class
17
+ end
18
+
19
+ def to_tex
20
+ latex.to_s
21
+ end
22
+
23
+ def to_gnu
24
+ gnu.to_s
25
+ end
26
+
27
+ def valued?
28
+ true
29
+ end
30
+ end
31
+
32
+ E = Constant.new(Math::E, :e, 'exp(1)')
33
+ PI = Constant.new(Math::PI, '\pi', :pi)
34
+ end
35
+
@@ -1,3 +1,3 @@
1
1
  module Danica
2
- VERSION = '2.0.0'
2
+ VERSION = '2.0.1'
3
3
  end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe Danica::Constant do
4
+ let(:subject) { described_class.new(2.5, :M, :m) }
5
+
6
+ describe '#to_f' do
7
+ it 'has a value' do
8
+ expect(subject.to_f).to eq(2.5)
9
+ end
10
+ end
11
+
12
+ describe '#to_tex' do
13
+ it 'has a string for latex' do
14
+ expect(subject.to_tex).to eq('M')
15
+ end
16
+ end
17
+
18
+ describe '#to_gnu' do
19
+ it 'has a string for gnu' do
20
+ expect(subject.to_gnu).to eq('m')
21
+ end
22
+ end
23
+
24
+ describe 'variables' do
25
+ it { expect(subject).not_to respond_to(:value=) }
26
+ it { expect(subject).not_to respond_to(:latex=) }
27
+ it { expect(subject).not_to respond_to(:gnu=) }
28
+ end
29
+ end
30
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danica
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darthjee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-24 00:00:00.000000000 Z
11
+ date: 2016-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -182,6 +182,7 @@ files:
182
182
  - lib/danica/common.rb
183
183
  - lib/danica/common/class_methods.rb
184
184
  - lib/danica/common/variables_builder.rb
185
+ - lib/danica/constant.rb
185
186
  - lib/danica/division.rb
186
187
  - lib/danica/exception.rb
187
188
  - lib/danica/exception/not_defined.rb
@@ -196,6 +197,7 @@ files:
196
197
  - lib/danica/sum.rb
197
198
  - lib/danica/variable.rb
198
199
  - lib/danica/version.rb
200
+ - spec/lib/danica/constant_spec.rb
199
201
  - spec/lib/danica/division_spec.rb
200
202
  - spec/lib/danica/exponential_spec.rb
201
203
  - spec/lib/danica/function_spec.rb
@@ -235,6 +237,7 @@ signing_key:
235
237
  specification_version: 4
236
238
  summary: Danica
237
239
  test_files:
240
+ - spec/lib/danica/constant_spec.rb
238
241
  - spec/lib/danica/division_spec.rb
239
242
  - spec/lib/danica/exponential_spec.rb
240
243
  - spec/lib/danica/function_spec.rb