sy 2.0.22 → 2.0.23
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 +4 -4
- data/README.md +12 -10
- data/lib/sy.rb +3 -0
- data/lib/sy/imperial.rb +6 -1
- data/lib/sy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdeb385f6bac717c48b1b299826a59503b248ca1
|
4
|
+
data.tar.gz: 687fdab4cf0ae4852ab2742e75a9728c3e509a0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c10acf0527df8ce1dab0afdfa9f4f65e526ac37a68ab4d8528fb48379ce5603c1049b6bbc14df3d75ef5a01450698c79c334aae448537707c9207cb9c99c7921
|
7
|
+
data.tar.gz: 560381bf7c8fd643037c50627a0d2a9241004e5cce6f19e9642261d4d71ccd42524ae5d77ba1d418340e35d965ec83e8f695b803fd0d61483ab0f6201047f7c7
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
# SY -
|
1
|
+
# SY - a physical units gem
|
2
2
|
|
3
|
-
`SY` is a domain model of physical units
|
3
|
+
`SY` is a domain model of physical units (magnitudes, quantities, dimensions...).
|
4
|
+
In `SY`, I (would like to) emphasize the domain model correctness and ease of use
|
5
|
+
over the ease of implementation. `SY` can be used in two modes:
|
4
6
|
|
5
7
|
* When loaded by `require 'sy'`, Numeric class is extended with methods
|
6
8
|
corresponding to units and their abbreviations.
|
@@ -8,18 +10,18 @@
|
|
8
10
|
while physical magnitudes can still be contructed explicitly from the
|
9
11
|
appropriate physical quantities.
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
+
Good manners require me to also mention another good library of physical units in
|
14
|
+
Ruby, [phys-units](https://github.com/masa16/phys-units).
|
13
15
|
|
14
16
|
## Usage
|
15
17
|
|
16
18
|
Upon `require 'sy'`, we can say `5.metre`, or `Rational( 5, 2 ).metre`, and the
|
17
|
-
computer will understand, that these numbers represent magnitudes of the
|
18
|
-
|
19
|
-
|
20
|
-
`5.
|
21
|
-
|
22
|
-
|
19
|
+
computer will understand, that these numbers represent magnitudes of the physical
|
20
|
+
quantity `SY::Length` expressed in the unit `SY::METRE`. Equally, we can use
|
21
|
+
abbreviations (such as `5.m`, `2.5.m`), prefixes (such as `5.km`, `5.kilometre`,
|
22
|
+
`5.km`), exponents (such as `5.m²` for 5 square metres), and chaining (such as
|
23
|
+
`5.m.s⁻¹` to denote speed of 5 metres per second). Please read also the code file
|
24
|
+
[https:://github.com/boris-s/lib/sy.rb] for the DSL statements defining default
|
23
25
|
quantities and their units.
|
24
26
|
|
25
27
|
## Unicode exponents
|
data/lib/sy.rb
CHANGED
data/lib/sy/imperial.rb
CHANGED
@@ -10,7 +10,8 @@ module SY
|
|
10
10
|
# short: 'in' would be ambiguous
|
11
11
|
FOOT = Unit.of Length, short: 'ft', amount: 12 * INCH
|
12
12
|
YARD = Unit.of Length, short: 'yd', amount: 3 * FOOT
|
13
|
-
# forget CHAIN
|
13
|
+
# forget CHAIN
|
14
|
+
FURLONG = Unit.of Length, short: 'fur', amount: 220 * YARD
|
14
15
|
MILE = Unit.of Length, short: 'mi', amount: 5_280 * FOOT
|
15
16
|
FATHOM = Unit.of Length, short: 'ftm', amount: 1.853184 * METRE
|
16
17
|
NAUTICAL_MILE = Unit.of Length, amount: 1000 * FATHOM
|
@@ -29,5 +30,9 @@ module SY
|
|
29
30
|
POUND = Unit.of Mass, short: 'lb', amount: 453.59237 * GRAM
|
30
31
|
OUNCE = Unit.of Mass, short: 'oz', amount: ( 1.0 / 16 ) * POUND
|
31
32
|
STONE = Unit.of Mass, amount: 14 * POUND
|
33
|
+
FIRKIN = Unit.of Mass, short: 'fir', amount: 90 * POUND
|
32
34
|
IMPERIAL_TON = Unit.of Mass, amount: 2240 * POUND
|
35
|
+
|
36
|
+
# === Time
|
37
|
+
FORTNIGHT = Unit.of Time, short: 'ftn', amount: 1_209_600 * SECOND
|
33
38
|
end
|
data/lib/sy/version.rb
CHANGED