pondize 0.0.7 → 0.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9596b4755cf63e546f8491291ce517d2c56d390d
4
- data.tar.gz: 3bc827843e654f9d29597397cc25393647c899c3
3
+ metadata.gz: 7ff01f9fc28e91d0969991e7c7a952390923ff2a
4
+ data.tar.gz: 2255403762289f5a486672bd93ee25a356e1610e
5
5
  SHA512:
6
- metadata.gz: af212cd08f9be9104ee065302ad8b7b1a11f5055d0d0aa758cf758d360cccb94cea86af92dccf5ab49903a691d9d9b63480c11ed19e33366e003321c81efffcd
7
- data.tar.gz: fa4d812ddd75e470572b49fcb5c5723315b02138d9c11972d60c86e2deb95970f91c233308f15197ab197c244506377f3235f15c8b90700280871bde8b501ac7
6
+ metadata.gz: 34219c7727da2c5157fd616b87a0c59c156038ee19516d3ea2909bb9b916662a16255a062067014a158b6217b261cac95fa554e60884052530a1d93f9a6ca344
7
+ data.tar.gz: f8a3cfbc56970ea36c318cd67f6260fddcac0f7fd2392d8608d2b1bf6c6cfc189f2303309d9f58e14db29ebc06ca586aa1e657bb3b8129302cd89ff5cc4a9fc8
@@ -12,4 +12,53 @@ module Pondize
12
12
  0
13
13
  end
14
14
  end
15
+
16
+ class Cv
17
+
18
+ CIRCLE = "fcgdaeb"
19
+
20
+ ACCIDENTALS = ['l', 'n', 's']
21
+
22
+ OCTAVES = [",", "'"]
23
+
24
+ def initialize key_signature, chars
25
+ @key_signature = key_signature
26
+ @chars = chars
27
+ end
28
+
29
+ def pondize
30
+ @chars.each_char
31
+ .map
32
+ .with_index { |char, index| (notes_to_change.include?(char) && !ACCIDENTALS.include?(@chars[index + 1]) ) ? "#{char}#{change_to}" : char }
33
+ .map.with_index { |char, index| (ACCIDENTALS + OCTAVES).include?(@chars[index + 1]) ? char : "#{char} " }
34
+ .join('')
35
+ .gsub('n', '')
36
+ .gsub(/ (\d)/, '\1')
37
+ .gsub('< <', '<<')
38
+ .gsub('> >', '>>')
39
+ .gsub(' .', '.')
40
+ .gsub('l', 'f')
41
+ end
42
+
43
+ def change_to
44
+ if @key_signature > 0
45
+ return 's'
46
+ end
47
+ if @key_signature < 0
48
+ return 's'
49
+ end
50
+ ''
51
+ end
52
+
53
+ def notes_to_change
54
+ if @key_signature > 0
55
+ return CIRCLE[0...@key_signature]
56
+ end
57
+ if @key_signature < 0
58
+ return CIRCLE[@key_signature..-1]
59
+ end
60
+ []
61
+ end
62
+ end
63
+
15
64
  end
@@ -1,3 +1,3 @@
1
1
  module Pondize
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
data/lib/pondize.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require "pondize/version"
2
2
 
3
3
  module Pondize
4
- require 'pondize/cv'
5
4
  require 'pondize/runner'
6
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pondize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Tokarski