ruby-mext 0.20.1 → 0.21.0
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/lib/mext/numeric/meter.rb +46 -0
- data/lib/mext/numeric.rb +1 -0
- data/lib/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 641330c8c2cd9031e4ef3be9947cff95bae6b687c3b1466843a3df066d53243f
|
4
|
+
data.tar.gz: 04e7e322a7dcbfc7da30fd8a5858aa52dda0c8201a83142118b58f65ba8780b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63b6f8e53ede313224d7ed45c65157b73bad7e5ced9436beac0efa9eb92f81331ac0e731dac6f3535917609014e670e1c3cd6a9aeabe66324566efc395d2a613
|
7
|
+
data.tar.gz: 107500aec8b7c15107192e71b0e23c780432c88d8f2964b1124ce293dbc10438213174ea4fd716804be1de39ae197c0ff265aee225013995c9344af45ddf9ccc
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Mext
|
2
|
+
module Numeric
|
3
|
+
|
4
|
+
#
|
5
|
+
# +Meter+:
|
6
|
+
#
|
7
|
+
# in music we cannot use the +Rational+ class
|
8
|
+
# because the latter will make all due conversions
|
9
|
+
# simplifying meters (like: 4/4 => 1/1), which is not what we want
|
10
|
+
#
|
11
|
+
class Meter
|
12
|
+
|
13
|
+
attr_accessor :numerator, :divisor
|
14
|
+
|
15
|
+
def initialize(n, d)
|
16
|
+
self.numerator = n.to_f
|
17
|
+
self.divisor = d.to_f
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# +Meter(n, d)+ is defined to actually mimick a +Rational()+
|
27
|
+
#
|
28
|
+
def Meter(n, d)
|
29
|
+
Mext::Numeric::Meter.new(n,d)
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# we extend the +String+ class to carry a +to_meter+ which
|
34
|
+
# will convert a string into a meter
|
35
|
+
#
|
36
|
+
class String
|
37
|
+
|
38
|
+
def to_meter
|
39
|
+
div = num = 1.0
|
40
|
+
(nums, divs) = self.split(/\s*\/\s*/, 2)
|
41
|
+
num = nums.to_f
|
42
|
+
div = divs.to_f
|
43
|
+
Meter(num, div)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
data/lib/mext/numeric.rb
CHANGED
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-mext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicola Bernardini
|
@@ -169,6 +169,7 @@ files:
|
|
169
169
|
- lib/mext/numeric/dbamp.rb
|
170
170
|
- lib/mext/numeric/ftom.rb
|
171
171
|
- lib/mext/numeric/gold.rb
|
172
|
+
- lib/mext/numeric/meter.rb
|
172
173
|
- lib/mext/numeric/mmtot.rb
|
173
174
|
- lib/mext/numeric/mround.rb
|
174
175
|
- lib/mext/numeric/mtof.rb
|