danica 2.0.0 → 2.0.1
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/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/lib/danica.rb +1 -0
- data/lib/danica/constant.rb +35 -0
- data/lib/danica/version.rb +1 -1
- data/spec/lib/danica/constant_spec.rb +30 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dee90fae6e225d80aa3ad1372b595e9ddb1838e
|
4
|
+
data.tar.gz: 4c48eb2ad5b03f32a548728b6753e72e0495ba9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 592db252b53a3a6a40288c12756338d5c94aedaff3a574e896ed2a011c6ea65d311d0b2786bbcfca00b9f4997be7f073e72981413805336fa92c5a3876c68cca
|
7
|
+
data.tar.gz: 669d72083cf2e11b9abaad19872e8d02c0cc31badea6a1612252bb0b18db64d2e416bda11fda10f9d66e4e97108f42ab490df3ee5c60d9cdc49ce633a0cb3ec7
|
data/Gemfile.lock
CHANGED
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
|
-
#####
|
194
|
+
##### calculate / to_f
|
195
195
|
```ruby
|
196
196
|
fx = Danica::Function::Spatial.new(
|
197
197
|
time: :t,
|
data/lib/danica.rb
CHANGED
@@ -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
|
+
|
data/lib/danica/version.rb
CHANGED
@@ -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.
|
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-
|
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
|