farski-systeme 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc ADDED
@@ -0,0 +1,67 @@
1
+ = Systeme - Dimensional declaration and conversion
2
+ === Now with more drachm!
3
+
4
+ Systeme provides an extensive but intuitive library of convenience methods for handling and passing around numeric data that represents dimensioned units (such as length, mass, and volume). Besides trimming down your code and making it more readable, it simplifies the task of storing data such that all values are stored in their standard SI base unit (meter, kilogram, etc).
5
+
6
+ = Usage
7
+
8
+ === Declarations
9
+
10
+ Declaration methods are the basis for utilizing systeme. Whenever a Numeric is declared with a systeme method, it will return an equivalent value in the SI standard base unit. These methods can be taken advantage of in several ways:
11
+
12
+ height_of_eiffel_tower = 325.meters
13
+ => 325
14
+ # 325 already represents the SI standard unit meter, so this just helps you read your code more easily
15
+
16
+ 10.kilometers
17
+ => 10000 # as in, 10 kilometers equals 10000 meters
18
+ # This allows you to quickly convert a number to it's equivalent base unit for storage
19
+
20
+ 120.miles + 14.furlongs + 191.megameters
21
+ => 191195937.632 # this value is in meters
22
+ # Declarations also make otherwise annoying calculations a snap
23
+
24
+ Systeme supports the five SI base units (meter, kilogram, ampere, second, kelvin) and all prefixed derivatives (pico-, nano-, kilo-, terra-, giga-, etc). Declarations can be made using any of a number of methods provided by these units.
25
+
26
+ 10.meter == 10.meters == 10.m
27
+ 10.kilogram == 10.kilograms == 10.kg
28
+
29
+ A growing number of U.S, Imperial, deprecated, and other non international standard units are also supported.
30
+
31
+ 10.pounds == 10.pound = 10.lb == 10.lbs == 10.lbm
32
+ 10.inches == 10.inch == 10.in
33
+ 10.foot == 10.feet == 10.foots == 10.ft
34
+
35
+ === Conversions
36
+
37
+ Conversions allow you to display or pass data in a unit other than the SI base. The set of methods for conversions is identical to declarations, but with each one prefixed by 'in_'. By declaring the numeric before converting it, any unit can be converted to any other unit. Non-declared numerics will be presumed to already be in their SI base unit
38
+
39
+ 1000.meters.in_kilometer
40
+ => 1
41
+ 16.oz.in_lb
42
+ => 1
43
+ 5280.in_miles
44
+ => 3.28083989501312
45
+ # 5280 was presumed to be in meters, if you were looking for a result of 1 you should do 5280.feet.in_miles
46
+
47
+ = Installation
48
+
49
+ === As a gem
50
+
51
+ The official distributions of this gem are available on RubyForge under the project name systeme
52
+
53
+ ==== this will be available soon
54
+
55
+ $ gem install systeme
56
+
57
+ Development can be followed on GitHub at http://www.gihub.com/farski/systeme
58
+
59
+ $ gem install farski-systeme
60
+
61
+ = Credits
62
+
63
+ Systeme is maintained by Chris Kalafarski
64
+
65
+ = License
66
+
67
+ Systeme is Copyright © 2008 Christopher P Kalafarski. It is free software, and may be redistributed under the terms specified in the LICENSE file.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 3
3
- :patch: 1
3
+ :patch: 2
4
4
  :major: 0
@@ -0,0 +1,23 @@
1
+ require 'systeme/registration'
2
+ require 'systeme/localize'
3
+
4
+ module Systeme
5
+ module Length
6
+ def self.included(caller)
7
+ caller.send :include, Systeme::Length::Declarations
8
+ end
9
+
10
+ module Units
11
+ Length = Hash.new
12
+ Length['astronomical_unit'] = { :si => 149597870691, :units => [ { :unit => 'astronomical_unit', :factor => 1, :aliases => ['AU', 'au'] } ] }
13
+ Length['barleycorn'] = { :si => 0.00846666667, :units => [ { :unit => 'barleycorn', :factor => 1 } ] }
14
+ Length['cubit'] = { :si => 0.5, :units => [ { :unit => 'cubit', :factor => 1 } ] }
15
+ Length['finger'] = { :si => 0.022225, :units => [ { :unit => 'finger', :factor => 1 } ] }
16
+ Length['hand'] = { :si => 0.1016, :units => [ { :unit => 'hand', :factor => 1 } ] }
17
+ end
18
+
19
+ module Declarations
20
+ Systeme::Localize::declare_system(Systeme::Length::Units::Length)
21
+ end
22
+ end
23
+ end
data/lib/systeme.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'systeme/international'
2
+ require 'systeme/localize'
2
3
  require 'systeme/metric'
3
4
  require 'systeme/imperial'
5
+ require 'systeme/length'
4
6
  require 'systeme/conversions'
5
7
  require 'systeme/registration'
6
8
 
@@ -9,6 +11,7 @@ module Systeme
9
11
  include Systeme::Localize
10
12
  include Systeme::Metric
11
13
  include Systeme::Imperial
14
+ include Systeme::Length
12
15
  include Systeme::Conversions
13
16
  end
14
17
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: farski-systeme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Kalafarski
@@ -22,11 +22,13 @@ extensions: []
22
22
  extra_rdoc_files: []
23
23
 
24
24
  files:
25
+ - README.rdoc
25
26
  - VERSION.yml
26
27
  - lib/systeme
27
28
  - lib/systeme/conversions.rb
28
29
  - lib/systeme/imperial.rb
29
30
  - lib/systeme/international.rb
31
+ - lib/systeme/length.rb
30
32
  - lib/systeme/localize.rb
31
33
  - lib/systeme/metric.rb
32
34
  - lib/systeme/registration.rb