phys-units 0.9.0 → 0.9.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.
@@ -3,6 +3,45 @@ require "helper"
3
3
 
4
4
  describe "Phys::Quantity" do
5
5
 
6
+ context "methods" do
7
+ describe Q[1.25,"km"] do
8
+ before {@q = Q[1.25,"km"]; @r = Q[500,"m"]}
9
+ it {@q.value.should == 1.25}
10
+ it {@q.expr.should == "km"}
11
+ it {@q.unit.should == Phys::Unit["km"]}
12
+ it {@q.want("cm").value.should == 125000}
13
+ it {(@q + @r).should == Q[1.75,"km"]}
14
+ it {(@q - @r).should == Q[0.75,"km"]}
15
+ it {@q.abs.should == Q[1.25,"km"]}
16
+ it {@q.abs2.should == Q[1.5625,"km^2"]}
17
+ it {@q.ceil.should == Q[2,"km"]}
18
+ it {@q.round.should == Q[1,"km"]}
19
+ it {@q.floor.should == Q[1,"km"]}
20
+ it {@q.truncate.should == Q[1,"km"]}
21
+ it {(+@q).should == Q[1.25,"km"]}
22
+ it {(-@q).should == Q[-1.25,"km"]}
23
+ it {(@q <=> @r).should == 1}
24
+ it {(@q == @r).should be_false}
25
+ it {(@q > @r).should be_true}
26
+ it {(@q >= @r).should be_true}
27
+ it {(@q < @r).should be_false}
28
+ it {(@q <= @r).should be_false}
29
+ it {(@q **2).should == Q[1.5625,"km^2"]}
30
+ it {(@q * @r).should == Q[0.625,"km^2"]}
31
+ it {(@q / @r).should == Q[2.5]}
32
+ it {(@q.quo @r).should == Q[2.5]}
33
+ it {(@q.div @r).should == 2}
34
+ it {(@q.div 0.5).should == Q[2,"km"]}
35
+ it {(@q % @r).should == 0.25}
36
+ it {(@q % 0.5).should == Q[0.25,"km"]}
37
+ it {(@q.divmod @r).should == [2,0.25]}
38
+ it {(@q.divmod 0.5).should == [Q[2,"km"],Q[0.25,"km"]]}
39
+ it {(@q.remainder @r).should == 0.25}
40
+ it {@q.to_base_unit.value.should == 1250}
41
+ end
42
+ end
43
+
44
+
6
45
  context "Dimensionless" do
7
46
  describe Q[1] do
8
47
  it {should be_an_instance_of Phys::Quantity}
data/spec/unit_spec.rb CHANGED
@@ -227,7 +227,7 @@ describe "Create Units" do
227
227
 
228
228
  describe "temperature unit" do
229
229
  it "operation error" do
230
- expect {U['tempC']*2}.to raise_error(Phys::Unit::UnitOperationError)
230
+ expect {U['tempC']*2}.to raise_error(Phys::UnitOperationError)
231
231
  end
232
232
  end
233
233
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phys-units
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro TANAKA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-27 00:00:00.000000000 Z
11
+ date: 2013-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,7 @@ files:
52
52
  - Rakefile
53
53
  - lib/phys/units.rb
54
54
  - lib/phys/units/Makefile
55
+ - lib/phys/units/errors.rb
55
56
  - lib/phys/units/load_units.rb
56
57
  - lib/phys/units/mixin.rb
57
58
  - lib/phys/units/parse.rb
@@ -62,6 +63,7 @@ files:
62
63
  - lib/phys/units/utils.rb
63
64
  - lib/phys/units/version.rb
64
65
  - phys-units.gemspec
66
+ - setup.rb
65
67
  - spec/helper.rb
66
68
  - spec/quantity_spec.rb
67
69
  - spec/unit_spec.rb
@@ -95,3 +97,4 @@ test_files:
95
97
  - spec/quantity_spec.rb
96
98
  - spec/unit_spec.rb
97
99
  - spec/utils_spec.rb
100
+ has_rdoc: