sy 2.0.22 → 2.0.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea2f55f3a2deb6fb8766eff1c6e72d10085e761f
4
- data.tar.gz: 01725b3cb13367650ca24a01037bf00214454cf1
3
+ metadata.gz: cdeb385f6bac717c48b1b299826a59503b248ca1
4
+ data.tar.gz: 687fdab4cf0ae4852ab2742e75a9728c3e509a0c
5
5
  SHA512:
6
- metadata.gz: 13ea62aae24ced86d136b1a62f561321f7ae05c26d38aff7b0cd2dbbfcc01f5a7f8346caa3bcab67de6452bf3608ccfadd612d64957821bfb1457ae3dabebfc5
7
- data.tar.gz: 3a471bda9369293a74d3e056663b32efd4b1d68725b585f6b212468123b7d2296d3352e3980c2fbf866c20f3cfc220da319955f70f797952f9a93eaa491d8526
6
+ metadata.gz: c10acf0527df8ce1dab0afdfa9f4f65e526ac37a68ab4d8528fb48379ce5603c1049b6bbc14df3d75ef5a01450698c79c334aae448537707c9207cb9c99c7921
7
+ data.tar.gz: 560381bf7c8fd643037c50627a0d2a9241004e5cce6f19e9642261d4d71ccd42524ae5d77ba1d418340e35d965ec83e8f695b803fd0d61483ab0f6201047f7c7
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
- # SY - The physical units library.
1
+ # SY - a physical units gem
2
2
 
3
- `SY` is a domain model of physical units. It can be used in two modes:
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
- At this place, good manners require me to mention the other good library of
12
- physical units in Ruby, [phys-units](https://github.com/masa16/phys-units).
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
- physical quantity `SY::Length` expressed in the unit `SY::METRE`. Equally,
19
- we can use abbreviations (such as `5.m`, `2.5.m`), prefixes (such as `5.km`,
20
- `5.kilometre`, `5.km`), exponents (such as `5.m²` for 5 square metres), and
21
- chaining (such as `5.m.s⁻¹` to denote speed of 5 metres per second). Please
22
- read also the code file lib/sy.rb for the DSL statements defining default
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
@@ -271,6 +271,9 @@ module SY
271
271
  # of its dimension.
272
272
  Speed = ( Length / Time ).standard!
273
273
 
274
+ # Common constant
275
+ SPEED_OF_LIGHT = 299_792_458 * METRE / SECOND
276
+
274
277
  # Similar for SY::Acceleration:
275
278
  Acceleration = ( Speed / Time ).standard!
276
279
 
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 and FURLONG
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
@@ -1,5 +1,5 @@
1
1
  module SY
2
- VERSION = "2.0.22"
2
+ VERSION = "2.0.23"
3
3
  DEBUG = false # debug mode switch - sometimes there are lines like
4
4
  # puts "something" if SY::DEBUG
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sy
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.22
4
+ version: 2.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - boris