units-system 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/units-system.rb +61 -61
- data/units-system.gemspec +4 -4
- metadata +25 -9
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/lib/units-system.rb
CHANGED
@@ -556,18 +556,17 @@ module Units
|
|
556
556
|
end
|
557
557
|
|
558
558
|
|
559
|
-
#
|
560
|
-
# In older Ruby versions, this must be included in any module or class from which units expressions
|
559
|
+
# This must be included in any module or class from which units expressions
|
561
560
|
# are to be used in units or u blocks.
|
561
|
+
# It is not needed in Ruby 1.9.1 due to they way constant loop-up is done in that version,
|
562
|
+
# but Ruby 1.9.2 has changed that an requires this again.
|
562
563
|
module UseBlocks
|
563
|
-
|
564
|
-
def
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
super
|
570
|
-
end
|
564
|
+
def self.append_features(target)
|
565
|
+
def target.const_missing(name)
|
566
|
+
begin
|
567
|
+
Units.Measure(name)
|
568
|
+
rescue ArgumentError
|
569
|
+
super
|
571
570
|
end
|
572
571
|
end
|
573
572
|
end
|
@@ -586,7 +585,7 @@ module Units
|
|
586
585
|
si_units :luminous_intensity, :cd # Iv
|
587
586
|
si_units :amount_of_substance, :mol # n
|
588
587
|
|
589
|
-
# base units
|
588
|
+
# define base units
|
590
589
|
define :g, 'gram', :mass, 1E-3
|
591
590
|
define :m, 'meter', :length, 1.0
|
592
591
|
define :s, 'second', :time, 1.0
|
@@ -595,76 +594,77 @@ module Units
|
|
595
594
|
define :cd,'candela',:luminous_intensity, 1.0
|
596
595
|
define :mol,'mole', :amount_of_substance, 1.0
|
597
596
|
|
598
|
-
|
599
|
-
|
600
|
-
define :d, 'day', 24, :h
|
601
|
-
define :mi, 'mile', 1.609344, :km
|
602
|
-
define :in, 'inch', 2.54, :cm
|
603
|
-
define :ft, 'foot', 0.3048, :m
|
604
|
-
# in is a Ruby keyword; to avoid having to use self.in we'll define:
|
605
|
-
define :inch, 'inch', 1, :in
|
606
|
-
define :lb, 'pound', 0.45359237, :kg
|
607
|
-
|
608
|
-
# declare derived quantities without named units
|
609
|
-
si_units :speed, u{m/s}
|
597
|
+
# declare derived quantities with no named units
|
598
|
+
si_units :speed, u{m/s}
|
610
599
|
si_units :acceleration, u{m/s**2}
|
611
|
-
si_units :area,
|
612
|
-
si_units :volume,
|
613
|
-
|
614
|
-
# named
|
615
|
-
define :W,
|
616
|
-
define :Hz,
|
617
|
-
define :N,
|
618
|
-
define :Pa,
|
619
|
-
define :J,
|
620
|
-
define :C,
|
621
|
-
define :V,
|
622
|
-
define :F,
|
623
|
-
define :Ω,
|
624
|
-
define :S,
|
625
|
-
define :Wb,'weber',
|
626
|
-
define :T,
|
627
|
-
define :H,
|
628
|
-
define :rad, 'radian',
|
629
|
-
define :sr,
|
630
|
-
define :lm,
|
631
|
-
define :lx,
|
632
|
-
define :Bq,
|
633
|
-
define :Gy,
|
634
|
-
define :Sv,
|
635
|
-
define :kat, 'katal',
|
636
|
-
|
637
|
-
|
600
|
+
si_units :area, u{m**2}
|
601
|
+
si_units :volume, u{m**3}
|
602
|
+
|
603
|
+
# derived quantities with named units
|
604
|
+
define :W, 'Watt', :power, u{kg*m**2/s**3} # J/s
|
605
|
+
define :Hz, 'herz', :frequency, u{1/s}
|
606
|
+
define :N, 'newton', :force, u{m*kg/s**2}
|
607
|
+
define :Pa, 'pascal', :pressure, u{N/m**2}
|
608
|
+
define :J, 'joule', :energy, u{N*m}
|
609
|
+
define :C, 'coulomb', :electric_charge, u{s*A}
|
610
|
+
define :V, 'volt', :voltage, u{W/A}
|
611
|
+
define :F, 'farad', :electric_capacitance, u{C/V}
|
612
|
+
define :Ω, 'ohm', :electric_resistance, u{V/A} # ohm: Ω omega: Ω
|
613
|
+
define :S, 'siemens', :electric_condctance, u{1/Ω}
|
614
|
+
define :Wb, 'weber', :magnetic_flux, u{J/A}
|
615
|
+
define :T, 'tesla', :magnetic_field, u{N/(A*m)}
|
616
|
+
define :H, 'henry', :inductance, u{Wb/A}
|
617
|
+
define :rad, 'radian', :angle, u{m/m}
|
618
|
+
define :sr, 'steradian', :solid_angle, u{m**2/m**2}
|
619
|
+
define :lm, 'lumen', :luminous_flux, u{cd*sr}
|
620
|
+
define :lx, 'lux', :illuminance, u{lm/m**2}
|
621
|
+
define :Bq, 'bequerel', :radioactivity, u{1/s}
|
622
|
+
define :Gy, 'gray', :absorbed_dose, u{J/kg}
|
623
|
+
define :Sv, 'sievert', :equivalent_dose, u{J/kg}
|
624
|
+
define :kat, 'katal', :catalytic_activity, u{mol/s}
|
625
|
+
|
626
|
+
# Other units
|
627
|
+
|
628
|
+
define :min, 'minute', 60, :s
|
629
|
+
define :h, 'hour', 60, :min
|
630
|
+
define :d, 'day', 24, :h
|
631
|
+
define :mi, 'mile', 1.609344, :km
|
632
|
+
define :in, 'inch', 2.54, :cm
|
633
|
+
define :ft, 'foot', 0.3048, :m
|
634
|
+
define :inch, 'inch', 1, :in # alternative to avoid having to use self.in (in is a Ruby keyword)
|
635
|
+
define :lb, 'pound', 0.45359237, :kg
|
636
|
+
|
637
|
+
define :°C, 'degree Celsius', 1, :K, +273.15
|
638
638
|
define :°F, 'degree Fahrenheit', 5.0/9.0, :K, +459.67
|
639
|
-
define :R,
|
639
|
+
define :R, 'rankine', 5.0/9.0, :K
|
640
640
|
|
641
641
|
define :l, 'litre', u{dm**3}
|
642
642
|
define :L, 'litre', 1, :l
|
643
643
|
|
644
|
-
define :°, 'degree',
|
644
|
+
define :°, 'degree', ::Math::PI/180.0, :rad
|
645
645
|
define :′, 'arc-minute', ::Math::PI/180.0/60.0, :rad
|
646
646
|
define :″, 'arc-second', ::Math::PI/180.0/3600.0, :rad
|
647
647
|
# not so cool, but easier to type alternatives:
|
648
|
-
define :deg,
|
648
|
+
define :deg, 'degree', 1, :°
|
649
649
|
define :arcmin, 'arc-minute', 1, :′
|
650
650
|
define :arcsec, 'arc-second', 1, :″
|
651
651
|
|
652
652
|
define :g0, 'standard gravity', u{9.80665*m/s**2}
|
653
653
|
|
654
|
-
define :bar,
|
655
|
-
define :atm,
|
656
|
-
define :mWC,
|
657
|
-
define :Torr, 'torricelli',
|
658
|
-
define :mHg,
|
654
|
+
define :bar, 'bar', 1E5, :Pa
|
655
|
+
define :atm, 'atmosphere', 101325.0, :Pa
|
656
|
+
define :mWC, 'meters of water column', u{1E3*kg*g0/m**2}
|
657
|
+
define :Torr, 'torricelli', u{atm/760}
|
658
|
+
define :mHg, 'mHg', u{13.5951E3*kg*g0/m**2}
|
659
659
|
|
660
660
|
# define :kp, 'kilopond', :force, u{kg*g0} # or define pond?
|
661
|
-
define :gf,
|
661
|
+
define :gf, 'gram-force', u{g*g0} # kilopond kp = kgf
|
662
662
|
define :lbf, 'pound-force', u{lb*g0}
|
663
663
|
|
664
|
-
define :dyn,
|
664
|
+
define :dyn, 'dyne', 10, :µN # u{1*g*cm/s**2}
|
665
665
|
define :galUS, 'U.S. liquid gallon', u{231*self.in**3}
|
666
666
|
define :galUK, 'Imperial gallon', 4.546092, :l
|
667
|
-
define :hp,
|
667
|
+
define :hp, 'horsepower', u{550*ft*lbf/s}
|
668
668
|
|
669
669
|
define :psi, 'pounds-force per square inch', u{lbf/self.in**2}
|
670
670
|
|
data/units-system.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{units-system}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Javier Goizueta"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-06-01}
|
13
13
|
s.description = %q{Experimental unit conversion & arithmetic for Ruby 1.9}
|
14
14
|
s.email = %q{jgoizueta@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.homepage = %q{http://github.com/jgoizueta/units-system}
|
32
32
|
s.rdoc_options = ["--charset=UTF-8"]
|
33
33
|
s.require_paths = ["lib"]
|
34
|
-
s.rubygems_version = %q{1.3.
|
34
|
+
s.rubygems_version = %q{1.3.7}
|
35
35
|
s.summary = %q{Arithmetic with units of measure}
|
36
36
|
s.test_files = [
|
37
37
|
"test/helper.rb",
|
@@ -42,7 +42,7 @@ Gem::Specification.new do |s|
|
|
42
42
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
43
43
|
s.specification_version = 3
|
44
44
|
|
45
|
-
if Gem::Version.new(Gem::
|
45
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
46
46
|
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
47
47
|
else
|
48
48
|
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: units-system
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 21
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Javier Goizueta
|
@@ -9,19 +15,23 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-
|
18
|
+
date: 2010-06-01 00:00:00 +02:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: thoughtbot-shoulda
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
27
|
- - ">="
|
22
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
23
32
|
version: "0"
|
24
|
-
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
25
35
|
description: Experimental unit conversion & arithmetic for Ruby 1.9
|
26
36
|
email: jgoizueta@gmail.com
|
27
37
|
executables: []
|
@@ -52,21 +62,27 @@ rdoc_options:
|
|
52
62
|
require_paths:
|
53
63
|
- lib
|
54
64
|
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
55
66
|
requirements:
|
56
67
|
- - ">="
|
57
68
|
- !ruby/object:Gem::Version
|
69
|
+
hash: 3
|
70
|
+
segments:
|
71
|
+
- 0
|
58
72
|
version: "0"
|
59
|
-
version:
|
60
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
61
75
|
requirements:
|
62
76
|
- - ">="
|
63
77
|
- !ruby/object:Gem::Version
|
78
|
+
hash: 3
|
79
|
+
segments:
|
80
|
+
- 0
|
64
81
|
version: "0"
|
65
|
-
version:
|
66
82
|
requirements: []
|
67
83
|
|
68
84
|
rubyforge_project:
|
69
|
-
rubygems_version: 1.3.
|
85
|
+
rubygems_version: 1.3.7
|
70
86
|
signing_key:
|
71
87
|
specification_version: 3
|
72
88
|
summary: Arithmetic with units of measure
|