sy 2.0.18 → 2.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +42 -18
- data/lib/sy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b523d585e50b7c1180421f3a08847057165daea9
|
4
|
+
data.tar.gz: 930162faffe96f611c8d61281375140e57922d6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d521ab97e1f86c694b88071f95f05c9ba3daf1e1148568d87d60d4c707311ab9dd3c7d5a779f679fcb646d69234e4db590af0189cf6fde0da57f784d51e2afe4
|
7
|
+
data.tar.gz: 1235ecdf7122635a711e96e2b3ff0c739fc7417d37af57abed3b358a64c00110bb13b56af5bac4e14fc280cd31260e5671367e9c40f8560e13b83521b93cec55
|
data/README.md
CHANGED
@@ -1,29 +1,53 @@
|
|
1
|
-
#
|
1
|
+
# SY - The physical units library.
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'sy'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install sy
|
3
|
+
The most prominent feature of SY is, that it extends the Numeric class
|
4
|
+
with methods corresponding to units and their abbreviations. At this place,
|
5
|
+
let me also make a polite mention of the other good physical units Ruby,
|
6
|
+
phys-units by Masahiro Tanaka, which seem to be inspired by GNU units.
|
18
7
|
|
19
8
|
## Usage
|
20
9
|
|
21
|
-
|
10
|
+
Upon require 'sy', we can say 5.metre, or Rational( 5, 2 ).metre, and the
|
11
|
+
computer will understand, that these numbers represent magnitudes of the
|
12
|
+
physical quantity SY::Length expressed in the unit SY::METRE. Equally,
|
13
|
+
we can use abbreviations (such as 5.m, 2.5.m), prefixes (such as 5.km,
|
14
|
+
5.kilometre, 5.km), exponents (such as 5.m² for 5 square metres) and
|
15
|
+
chaining (such as 5.m.s⁻¹ to denote speed of 5 metres per second). Please
|
16
|
+
read also the code file lib/sy.rb, where you can find the examples of the
|
17
|
+
DSL used to define quantities and their units.
|
18
|
+
|
19
|
+
## Unicode exponents
|
20
|
+
|
21
|
+
You should definitely learn how to type Unicode exponent characters, such
|
22
|
+
as ², ³, ⁻¹ etc. It is possible to use alterantive syntax such as 5.m.s(-1)
|
23
|
+
instead of 5.m.s⁻¹, but Unicode exponents should be used everywere except
|
24
|
+
non-reused code. Unicode exponents make the physical models that you will
|
25
|
+
be constructing with SY much more readable. And we know that code is (usually)
|
26
|
+
write once, read many times. So it pays off to type an extra keystroke when
|
27
|
+
writing, and that way buy more model readability for the many subsequent
|
28
|
+
revisions.
|
29
|
+
|
30
|
+
## Method collisions
|
31
|
+
|
32
|
+
One more remark here would be, that due to the fact, that many unit names
|
33
|
+
and abbreviations are very short and common words, there can be collisions.
|
34
|
+
For example ActiveSupport already provides handling for time units (hour,
|
35
|
+
minute, second etc.), which would collide with SY methods of the same name.
|
36
|
+
Since SY relies on method_missing, if these methods are already defined for
|
37
|
+
numerics, SY's method_missing will not activate and ActiveSupport methods
|
38
|
+
will be used. In this particular case, SY methods still can be invoked using
|
39
|
+
abbreviations (5.s, 5.h, 5.min).
|
22
40
|
|
23
41
|
## Contributing
|
24
42
|
|
43
|
+
SY has been written emphasizing the object model over plentitude of defined
|
44
|
+
units. There is plenty of room for defining units thus far not defined by SY.
|
45
|
+
Also, the object model, though advanced, could possibly be refactored, eg.
|
46
|
+
with respect to the way that parametrized descendants of Magnitude are
|
47
|
+
introduced.
|
48
|
+
|
25
49
|
1. Fork it
|
26
50
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
51
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
52
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|
53
|
+
5. Create new Pull Request
|
data/lib/sy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- boris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|