morsecode 0.1.2 → 0.1.3
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.
- data/lib/morsecode.rb +7 -9
- metadata +20 -11
data/lib/morsecode.rb
CHANGED
@@ -1,26 +1,24 @@
|
|
1
|
-
#!/usr/bin/ruby
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
# file: morsecode.rb
|
4
4
|
|
5
|
-
require '
|
5
|
+
require 'dynarex'
|
6
6
|
|
7
7
|
class MorseCode
|
8
|
-
include REXML
|
9
8
|
|
10
|
-
def initialize(
|
9
|
+
def initialize(input_string)
|
11
10
|
buffer = File.open(File.dirname(__FILE__) + '/morsecode.xml','r').read
|
12
|
-
|
13
|
-
@h = Hash[XPath.match(doc.root, 'records/code').map{|x| x.map{|name| name.text.to_s}}]
|
11
|
+
@h = Hash[Dynarex.new(buffer).to_h.map{|x| x.values[0..1]}]
|
14
12
|
|
15
|
-
@
|
13
|
+
@input_string = input_string
|
16
14
|
end
|
17
15
|
|
18
16
|
def to_s
|
19
|
-
@
|
17
|
+
@input_string.split(/4/).map{|code| @h[code]}.join()
|
20
18
|
end
|
21
19
|
|
22
20
|
def to_mc
|
23
|
-
@
|
21
|
+
@input_string.split(//).map{|char| @h.invert[char]}.join('4')
|
24
22
|
end
|
25
23
|
|
26
24
|
end
|
metadata
CHANGED
@@ -1,18 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: morsecode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.3
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
-
|
7
|
+
authors:
|
8
|
+
- James Robertson
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
12
|
|
12
|
-
date:
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
date: 2012-12-29 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: dynarex
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
16
26
|
description:
|
17
27
|
email:
|
18
28
|
executables: []
|
@@ -24,7 +34,6 @@ extra_rdoc_files: []
|
|
24
34
|
files:
|
25
35
|
- lib/morsecode.rb
|
26
36
|
- lib/morsecode.xml
|
27
|
-
has_rdoc: true
|
28
37
|
homepage:
|
29
38
|
licenses: []
|
30
39
|
|
@@ -34,21 +43,21 @@ rdoc_options: []
|
|
34
43
|
require_paths:
|
35
44
|
- lib
|
36
45
|
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
37
47
|
requirements:
|
38
48
|
- - ">="
|
39
49
|
- !ruby/object:Gem::Version
|
40
50
|
version: "0"
|
41
|
-
version:
|
42
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
43
53
|
requirements:
|
44
54
|
- - ">="
|
45
55
|
- !ruby/object:Gem::Version
|
46
56
|
version: "0"
|
47
|
-
version:
|
48
57
|
requirements: []
|
49
58
|
|
50
59
|
rubyforge_project:
|
51
|
-
rubygems_version: 1.
|
60
|
+
rubygems_version: 1.8.23
|
52
61
|
signing_key:
|
53
62
|
specification_version: 3
|
54
63
|
summary: morsecode
|