quantity 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +2 -0
- data/README +14 -0
- data/UNLICENSE +24 -0
- data/VERSION +1 -0
- data/lib/quantity.rb +17 -0
- data/lib/quantity/unit.rb +28 -0
- data/lib/quantity/unit/current.rb +9 -0
- data/lib/quantity/unit/length.rb +9 -0
- data/lib/quantity/unit/luminosity.rb +9 -0
- data/lib/quantity/unit/mass.rb +9 -0
- data/lib/quantity/unit/substance.rb +9 -0
- data/lib/quantity/unit/temperature.rb +9 -0
- data/lib/quantity/unit/time.rb +9 -0
- data/lib/quantity/version.rb +19 -0
- metadata +88 -0
data/AUTHORS
ADDED
data/README
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Quantity.rb: Units and Quantities for Ruby
|
2
|
+
==========================================
|
3
|
+
|
4
|
+
Authors
|
5
|
+
-------
|
6
|
+
|
7
|
+
* [Ben Lavender](mailto:blavender@gmail.com) - <http://bhuga.net/>
|
8
|
+
* [Arto Bendiken](mailto:arto.bendiken@gmail.com) - <http://ar.to/>
|
9
|
+
|
10
|
+
License
|
11
|
+
-------
|
12
|
+
|
13
|
+
Quantity.rb is free and unencumbered public domain software. For more
|
14
|
+
information, see <http://unlicense.org/> or the accompanying UNLICENSE file.
|
data/UNLICENSE
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
4
|
+
distribute this software, either in source code form or as a compiled
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
6
|
+
means.
|
7
|
+
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
9
|
+
of this software dedicate any and all copyright interest in the
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
11
|
+
of the public at large and to the detriment of our heirs and
|
12
|
+
successors. We intend this dedication to be an overt act of
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
14
|
+
software under copyright law.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
For more information, please refer to <http://unlicense.org/>
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
data/lib/quantity.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'quantity/version'
|
2
|
+
|
3
|
+
class Quantity
|
4
|
+
autoload :Unit, 'quantity/unit'
|
5
|
+
|
6
|
+
undef_method *(instance_methods - %w(__id__ __send__ __class__ __eval__ instance_eval inspect))
|
7
|
+
|
8
|
+
attr_reader :value
|
9
|
+
attr_reader :unit
|
10
|
+
|
11
|
+
##
|
12
|
+
# @param [Numeric] value
|
13
|
+
# @param [Unit] unit
|
14
|
+
def initialize(value, unit)
|
15
|
+
@value, @unit = value, unit
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class Quantity
|
2
|
+
class Unit
|
3
|
+
autoload :Length, 'quantity/unit/length'
|
4
|
+
autoload :Mass, 'quantity/unit/mass'
|
5
|
+
autoload :Time, 'quantity/unit/time'
|
6
|
+
autoload :Current, 'quantity/unit/current'
|
7
|
+
autoload :Temperature, 'quantity/unit/temperature'
|
8
|
+
autoload :Luminosity, 'quantity/unit/luminosity'
|
9
|
+
autoload :Substance, 'quantity/unit/substance'
|
10
|
+
|
11
|
+
# @return [String]
|
12
|
+
attr_reader :name
|
13
|
+
|
14
|
+
alias_method :to_s, :name
|
15
|
+
|
16
|
+
##
|
17
|
+
# @param [String] name
|
18
|
+
def initialize(name = nil)
|
19
|
+
@name = name || self.class.name.split(':').last.downcase
|
20
|
+
end
|
21
|
+
|
22
|
+
##
|
23
|
+
# @return [Symbol]
|
24
|
+
def to_sym
|
25
|
+
name.to_sym
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Quantity
|
2
|
+
module VERSION
|
3
|
+
MAJOR = 0
|
4
|
+
MINOR = 0
|
5
|
+
TINY = 0
|
6
|
+
EXTRA = nil
|
7
|
+
|
8
|
+
STRING = [MAJOR, MINOR, TINY].join('.')
|
9
|
+
STRING << "-#{EXTRA}" if EXTRA
|
10
|
+
|
11
|
+
##
|
12
|
+
# @return [String]
|
13
|
+
def self.to_s() STRING end
|
14
|
+
|
15
|
+
##
|
16
|
+
# @return [String]
|
17
|
+
def self.to_str() STRING end
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: quantity
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Lavender
|
8
|
+
- Arto Bendiken
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2009-12-29 00:00:00 +01:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rspec
|
18
|
+
type: :development
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 1.2.9
|
25
|
+
version:
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: yard
|
28
|
+
type: :development
|
29
|
+
version_requirement:
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.5.2
|
35
|
+
version:
|
36
|
+
description: Units and quantities for Ruby.
|
37
|
+
email: blavender@gmail.com
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files: []
|
43
|
+
|
44
|
+
files:
|
45
|
+
- AUTHORS
|
46
|
+
- README
|
47
|
+
- UNLICENSE
|
48
|
+
- VERSION
|
49
|
+
- lib/quantity/unit/current.rb
|
50
|
+
- lib/quantity/unit/length.rb
|
51
|
+
- lib/quantity/unit/luminosity.rb
|
52
|
+
- lib/quantity/unit/mass.rb
|
53
|
+
- lib/quantity/unit/substance.rb
|
54
|
+
- lib/quantity/unit/temperature.rb
|
55
|
+
- lib/quantity/unit/time.rb
|
56
|
+
- lib/quantity/unit.rb
|
57
|
+
- lib/quantity/version.rb
|
58
|
+
- lib/quantity.rb
|
59
|
+
has_rdoc: false
|
60
|
+
homepage: http://quantity.rubyforge.org/
|
61
|
+
licenses:
|
62
|
+
- Public Domain
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 1.8.2
|
73
|
+
version:
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
version:
|
80
|
+
requirements: []
|
81
|
+
|
82
|
+
rubyforge_project: quantity
|
83
|
+
rubygems_version: 1.3.5
|
84
|
+
signing_key:
|
85
|
+
specification_version: 3
|
86
|
+
summary: Units and quantities for Ruby.
|
87
|
+
test_files: []
|
88
|
+
|