unitwise 0.1.0 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e61cddd2199fa0eb4c5bf1ef9f8765e6abf7c1dd
4
- data.tar.gz: fe384987b89b94a4a7f7e166bdc0b1119f98686e
3
+ metadata.gz: 7b43a98361a2647155beb5a86d6bc1281e8f160c
4
+ data.tar.gz: 25dbd408ecc497a0003592c17c41b3636537d2bb
5
5
  SHA512:
6
- metadata.gz: acc76a1ae389f002106bc3ec9913f5377b0470ec3fd056d2879fc40bbf009594e7aa69251026b88f62a084c9bc28fdbb8b4292aaab1bd8c94e3fb8df857a24d4
7
- data.tar.gz: 5491cbd50d20baf23e431831df67a073bdd0123007cc310d41cf027bbb64746de2d7dd44858343f39c584a7ef510fdf3c48d4d34f5242bb5fcb5dc893cd06d41
6
+ metadata.gz: 1e1b4d53bc2c1cbe081df9a5df31d82872ae390773831558137fba10139d27fb9e4fab531149f5f876a5c4a7bf57d97340ef70e671d0fbabaa5c930a953f96a1
7
+ data.tar.gz: f17f89d11af392f7c9b520ad4defe197ddf9657ccb7bce721923f59a229caf5336ab892653c01fc9f6d5d546864bca1b7c298cd5e56ccb54e480e80fcc90bc8e
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Unitwise
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/unitwise.png)](http://badge.fury.io/rb/unitwise)
3
4
  [![Build Status](https://travis-ci.org/joshwlewis/unitwise.png)](https://travis-ci.org/joshwlewis/unitwise)
4
5
  [![Dependency Status](https://gemnasium.com/joshwlewis/unitwise.png)](https://gemnasium.com/joshwlewis/unitwise)
5
6
  [![Coverage Status](https://coveralls.io/repos/joshwlewis/unitwise/badge.png)](https://coveralls.io/r/joshwlewis/unitwise)
@@ -10,8 +11,6 @@ Unitwise is a library for performing mathematical operations and conversions on
10
11
 
11
12
  Unitwise supports a vast number of units. At the time of writing, it supports 95 metric units, 199 non-metric units, and 24 unit prefixes. That's approximately 2,500 basic units, but these can also be combined through multiplication and/or division to create an infinite number of possibilities.
12
13
 
13
- Please note that while Unitwise is functional, it is still under development.
14
-
15
14
  ## Usage
16
15
 
17
16
  ### Initialization:
@@ -630,7 +630,7 @@
630
630
  :primary_code: AU
631
631
  :secondary_code: ASU
632
632
  :scale:
633
- :value: 149597.87
633
+ :value: 149597.870691
634
634
  :unit_code: Mm
635
635
  :classification: iso1000
636
636
  :property: length
@@ -688,7 +688,7 @@
688
688
  - :names: permittivity of vacuum
689
689
  :symbol: <i>ε<sub><r>0</r></sub></i>
690
690
  :primary_code: '[eps_0]'
691
- :secondary_code: '[eps_0]'
691
+ :secondary_code: '[EPS_0]'
692
692
  :scale:
693
693
  :value: 8.854187817e-12
694
694
  :unit_code: F/m
@@ -700,7 +700,7 @@
700
700
  - :names: permeability of vacuum
701
701
  :symbol: <i>μ<sub><r>0</r></sub></i>
702
702
  :primary_code: '[mu_0]'
703
- :secondary_code: '[mu_0]'
703
+ :secondary_code: '[MU_0]'
704
704
  :scale:
705
705
  :value: 1.0
706
706
  :unit_code: 4.[pi].10*-7.N/A2
@@ -1754,6 +1754,51 @@
1754
1754
  :metric: false
1755
1755
  :special: false
1756
1756
  :arbitrary: false
1757
+ - :names: metric fluid ounce
1758
+ :symbol: oz fl
1759
+ :primary_code: '[foz_m]'
1760
+ :secondary_code: '[FOZ_M]'
1761
+ :scale:
1762
+ :value: 30.0
1763
+ :unit_code: mL
1764
+ :classification: us-volumes
1765
+ :property: fluid volume
1766
+ :metric: false
1767
+ :special: false
1768
+ :arbitrary: false
1769
+ - :names: metric cup
1770
+ :primary_code: '[cup_m]'
1771
+ :secondary_code: '[CUP_M]'
1772
+ :scale:
1773
+ :value: 240.0
1774
+ :unit_code: mL
1775
+ :classification: us-volumes
1776
+ :property: volume
1777
+ :metric: false
1778
+ :special: false
1779
+ :arbitrary: false
1780
+ - :names: metric teaspoon
1781
+ :primary_code: '[tsp_m]'
1782
+ :secondary_code: '[TSP_M]'
1783
+ :scale:
1784
+ :value: 5.0
1785
+ :unit_code: mL
1786
+ :classification: us-volumes
1787
+ :property: volume
1788
+ :metric: false
1789
+ :special: false
1790
+ :arbitrary: false
1791
+ - :names: metric tablespoon
1792
+ :primary_code: '[tbs_m]'
1793
+ :secondary_code: '[TBS_M]'
1794
+ :scale:
1795
+ :value: 15.0
1796
+ :unit_code: mL
1797
+ :classification: us-volumes
1798
+ :property: volume
1799
+ :metric: false
1800
+ :special: false
1801
+ :arbitrary: false
1757
1802
  - :names: gallon
1758
1803
  :primary_code: '[gal_br]'
1759
1804
  :secondary_code: '[GAL_BR]'
@@ -2043,6 +2088,17 @@
2043
2088
  :metric: false
2044
2089
  :special: false
2045
2090
  :arbitrary: false
2091
+ - :names: metric ounce
2092
+ :primary_code: '[oz_m]'
2093
+ :secondary_code: '[OZ_M]'
2094
+ :scale:
2095
+ :value: 28.0
2096
+ :unit_code: g
2097
+ :classification: apoth
2098
+ :property: mass
2099
+ :metric: false
2100
+ :special: false
2101
+ :arbitrary: false
2046
2102
  - :names: line
2047
2103
  :primary_code: '[lne]'
2048
2104
  :secondary_code: '[LNE]'
@@ -2176,6 +2232,18 @@
2176
2232
  :metric: false
2177
2233
  :special: true
2178
2234
  :arbitrary: false
2235
+ - :names: degree Rankine
2236
+ :symbol: °R
2237
+ :primary_code: '[degR]'
2238
+ :secondary_code: '[degR]'
2239
+ :scale:
2240
+ :value: 5.0
2241
+ :unit_code: K/9
2242
+ :classification: heat
2243
+ :property: temperature
2244
+ :metric: false
2245
+ :special: false
2246
+ :arbitrary: false
2179
2247
  - :names: calorie at 15 °C
2180
2248
  :symbol: cal<sub>15°C</sub>
2181
2249
  :primary_code: cal_[15]
@@ -2355,6 +2423,30 @@
2355
2423
  :metric: false
2356
2424
  :special: false
2357
2425
  :arbitrary: false
2426
+ - :names: tex
2427
+ :symbol: tex
2428
+ :primary_code: tex
2429
+ :secondary_code: TEX
2430
+ :scale:
2431
+ :value: 1.0
2432
+ :unit_code: g/km
2433
+ :classification: heat
2434
+ :property: linear mass density (of textile thread)
2435
+ :metric: true
2436
+ :special: false
2437
+ :arbitrary: false
2438
+ - :names: Denier
2439
+ :symbol: den
2440
+ :primary_code: '[den]'
2441
+ :secondary_code: '[DEN]'
2442
+ :scale:
2443
+ :value: 1.0
2444
+ :unit_code: g/9/km
2445
+ :classification: heat
2446
+ :property: linear mass density (of textile thread)
2447
+ :metric: false
2448
+ :special: false
2449
+ :arbitrary: false
2358
2450
  - :names: meter of water column
2359
2451
  :symbol: m H<sub><r>2</r></sub>O
2360
2452
  :primary_code: m[H2O]
@@ -2394,7 +2486,7 @@
2394
2486
  - :names: inch of mercury column
2395
2487
  :symbol: in Hg
2396
2488
  :primary_code: '[in_i''Hg]'
2397
- :secondary_code: '[IN_i''HG]'
2489
+ :secondary_code: '[IN_I''HG]'
2398
2490
  :scale:
2399
2491
  :value: 1.0
2400
2492
  :unit_code: m[Hg].[in_i]/m
@@ -2484,7 +2576,7 @@
2484
2576
  :secondary_code: '[CH]'
2485
2577
  :scale:
2486
2578
  :value: 1.0
2487
- :unit_code: mm/[pi]
2579
+ :unit_code: mm/3
2488
2580
  :classification: clinical
2489
2581
  :property: gauge of catheters
2490
2582
  :metric: false
@@ -2496,7 +2588,7 @@
2496
2588
  :secondary_code: '[DRP]'
2497
2589
  :scale:
2498
2590
  :value: 1.0
2499
- :unit_code: ml/12
2591
+ :unit_code: ml/20
2500
2592
  :classification: clinical
2501
2593
  :property: volume
2502
2594
  :metric: false
@@ -2875,6 +2967,17 @@
2875
2967
  :metric: false
2876
2968
  :special: false
2877
2969
  :arbitrary: true
2970
+ - :names: anti factor Xa unit
2971
+ :primary_code: '[anti''Xa''U]'
2972
+ :secondary_code: '[ANTI''XA''U]'
2973
+ :scale:
2974
+ :value: 1.0
2975
+ :unit_code: '1'
2976
+ :classification: chemical
2977
+ :property: biologic activity of factor Xa inhibitor (heparin)
2978
+ :metric: false
2979
+ :special: false
2980
+ :arbitrary: true
2878
2981
  - :names: Todd unit
2879
2982
  :primary_code: '[todd''U]'
2880
2983
  :secondary_code: '[TODD''U]'
@@ -2987,6 +3090,18 @@
2987
3090
  :metric: false
2988
3091
  :special: false
2989
3092
  :arbitrary: true
3093
+ - :names: 50% embryo infectious dose
3094
+ :symbol: EID<sub>50</sub>
3095
+ :primary_code: '[EID_50]'
3096
+ :secondary_code: '[EID_50]'
3097
+ :scale:
3098
+ :value: 1.0
3099
+ :unit_code: '1'
3100
+ :classification: chemical
3101
+ :property: biologic activity (infectivity) of an infectious agent preparation
3102
+ :metric: false
3103
+ :special: false
3104
+ :arbitrary: true
2990
3105
  - :names: plaque forming units
2991
3106
  :symbol: PFU
2992
3107
  :primary_code: '[PFU]'
@@ -3091,7 +3206,40 @@
3091
3206
  :value: 1.0
3092
3207
  :unit_code: '1'
3093
3208
  :classification: chemical
3094
- :property: procedure defined amount of an antigen substance
3209
+ :property: procedure defined amount of a poliomyelitis d-antigen substance
3210
+ :metric: false
3211
+ :special: false
3212
+ :arbitrary: true
3213
+ - :names: fibrinogen equivalent unit
3214
+ :primary_code: '[FEU]'
3215
+ :secondary_code: '[FEU]'
3216
+ :scale:
3217
+ :value: 1.0
3218
+ :unit_code: '1'
3219
+ :classification: chemical
3220
+ :property: amount of fibrinogen broken down into the measured d-dimers
3221
+ :metric: false
3222
+ :special: false
3223
+ :arbitrary: true
3224
+ - :names: ELISA unit
3225
+ :primary_code: '[ELU]'
3226
+ :secondary_code: '[ELU]'
3227
+ :scale:
3228
+ :value: 1.0
3229
+ :unit_code: '1'
3230
+ :classification: chemical
3231
+ :property: arbitrary ELISA unit
3232
+ :metric: false
3233
+ :special: false
3234
+ :arbitrary: true
3235
+ - :names: Ehrlich unit
3236
+ :primary_code: '[EU]'
3237
+ :secondary_code: '[EU]'
3238
+ :scale:
3239
+ :value: 1.0
3240
+ :unit_code: '1'
3241
+ :classification: chemical
3242
+ :property: Ehrlich unit
3095
3243
  :metric: false
3096
3244
  :special: false
3097
3245
  :arbitrary: true
@@ -3383,7 +3531,7 @@
3383
3531
  - :names: baud
3384
3532
  :symbol: Bd
3385
3533
  :primary_code: Bd
3386
- :secondary_code: Bd
3534
+ :secondary_code: BD
3387
3535
  :scale:
3388
3536
  :value: 1.0
3389
3537
  :unit_code: /s
@@ -63,7 +63,7 @@ module Unitwise
63
63
  base? ? 1 : scale.scalar
64
64
  end
65
65
 
66
- def functional(x, direction=1)
66
+ def functional(x=scalar, direction=1)
67
67
  scale.functional(x, direction)
68
68
  end
69
69
 
@@ -9,11 +9,11 @@ module Unitwise
9
9
  end
10
10
 
11
11
  def scalar
12
- puts "Warning: Mathematical operations with special units should be used with caution."
12
+ puts "Warning: Mathematical operations with special units not reccomended by UCUM."
13
13
  super()
14
14
  end
15
15
 
16
- def functional(x, direction=1)
16
+ def functional(x=scalar, direction=1)
17
17
  function.functional(x, direction)
18
18
  end
19
19
 
@@ -53,11 +53,11 @@ module Unitwise
53
53
  if other_unit.special?
54
54
  other_unit.functional functional(value, -1)
55
55
  else
56
- functional(value, -1)
56
+ functional(value, -1) / other_unit.scalar
57
57
  end
58
58
  else
59
59
  if other_unit.special?
60
- other_unit.functional(value)
60
+ other_unit.functional(scalar)
61
61
  else
62
62
  scalar / other_unit.scalar
63
63
  end
@@ -25,8 +25,8 @@ module Unitwise
25
25
  unit.special?
26
26
  end
27
27
 
28
- def functional(value, direction=1)
29
- unit.functional(value, direction)
28
+ def functional(x=value, direction=1)
29
+ unit.functional(x, direction)
30
30
  end
31
31
 
32
32
  def scalar
@@ -53,8 +53,8 @@ module Unitwise
53
53
  (factor * (prefix ? prefix.scalar : 1) * (atom ? atom.scalar : 1)) ** exponent
54
54
  end
55
55
 
56
- def functional(value, direction=1)
57
- (factor * (prefix ? prefix.scalar : 1)) * (atom ? atom.functional(value, direction) : 1) ** exponent
56
+ def functional(x=scalar, direction=1)
57
+ (factor * (prefix ? prefix.scalar : 1)) * (atom ? atom.functional(x, direction) : 1) ** exponent
58
58
  end
59
59
 
60
60
  def root_terms
@@ -29,8 +29,8 @@ module Unitwise
29
29
  terms.count == 1 && terms.all?(&:special?)
30
30
  end
31
31
 
32
- def functional(value, direction=1)
33
- terms.first.functional(value, direction)
32
+ def functional(x=scalar, direction=1)
33
+ terms.first.functional(x, direction)
34
34
  end
35
35
 
36
36
  def dup
@@ -1,3 +1,3 @@
1
1
  module Unitwise
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -42,6 +42,7 @@ describe Unitwise::Measurement do
42
42
  let(:cel) { Unitwise::Measurement.new(22, 'Cel') }
43
43
  let(:k) {Unitwise::Measurement.new(373.15, 'K') }
44
44
  let(:f) {Unitwise::Measurement.new(98.6, '[degF]')}
45
+ let(:r) { Unitwise::Measurement.new(491.67, '[degR]') }
45
46
 
46
47
  describe "#scalar" do
47
48
  it "must return value relative to terminal atoms" do
@@ -66,6 +67,12 @@ describe Unitwise::Measurement do
66
67
  it "must convert special units to special units" do
67
68
  f.convert('Cel').value.must_equal 37
68
69
  end
70
+ it "must convert special units to non-special units" do
71
+ cel.convert("[degR]").value.must_equal 531.27
72
+ end
73
+ it "must convert derived units to special units" do
74
+ r.convert("Cel").value.round.must_equal 0
75
+ end
69
76
  end
70
77
 
71
78
  describe "#*" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unitwise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Lewis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-30 00:00:00.000000000 Z
11
+ date: 2013-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: signed_multiset
@@ -210,4 +210,3 @@ test_files:
210
210
  - test/unitwise/term_test.rb
211
211
  - test/unitwise/unit_test.rb
212
212
  - test/unitwise_test.rb
213
- has_rdoc: