MorseConverter 0.0.1

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.
Files changed (2) hide show
  1. data/lib/morsecode.rb +57 -0
  2. metadata +62 -0
data/lib/morsecode.rb ADDED
@@ -0,0 +1,57 @@
1
+ class MorseCode
2
+ @@map = nil
3
+ def initialize
4
+ if @@map == nil then
5
+ @@map = Hash.new
6
+ @@map["a"] = ". _"
7
+ @@map["b"] = "_ . . ."
8
+ @@map["c"] = "_ . _ ."
9
+ @@map["d"] = "_ . ."
10
+ @@map["e"] = "."
11
+ @@map["f"] = ". . _ ."
12
+ @@map["g"] = "_ _ ."
13
+ @@map["h"] = ". . . ."
14
+ @@map["i"] = ". ."
15
+ @@map["j"] = ". _ _ _"
16
+ @@map["k"] = "_ . _"
17
+ @@map["l"] = ". _ . ."
18
+ @@map["m"] = "_ _"
19
+ @@map["n"] = "_ ."
20
+ @@map["o"] = "_ _ _"
21
+ @@map["p"] = ". _ _ ."
22
+ @@map["q"] = "_ _ . _"
23
+ @@map["r"] = ". _ ."
24
+ @@map["s"] = ". . ."
25
+ @@map["t"] = "_"
26
+ @@map["u"] = ". . _"
27
+ @@map["v"] = ". . . _"
28
+ @@map["w"] = ". _ _"
29
+ @@map["x"] = "_ . . _"
30
+ @@map["y"] = "_ . _ _"
31
+ @@map["z"] = "_ _ . ."
32
+ @@map["0"] = "_ _ _ _ _"
33
+ @@map["1"] = ". _ _ _ _"
34
+ @@map["2"] = ". . _ _ _"
35
+ @@map["3"] = ". . . _ _"
36
+ @@map["4"] = ". . . . _"
37
+ @@map["5"] = ". . . . ."
38
+ @@map["6"] = "_ . . . ."
39
+ @@map["7"] = "_ _ . . ."
40
+ @@map["8"] = "_ _ _ . ."
41
+ @@map["9"] = "_ _ _ _ ."
42
+ @@map[" "] = "+"
43
+ end
44
+ end
45
+ def convert text
46
+ unless text.match /[a-zA-Z0-9 ]/
47
+ "Please use alpha-numeric characters right now"
48
+ else
49
+ output = ""
50
+ text.split("").each do |char|
51
+ output = output + @@map[char]
52
+ end
53
+ output
54
+ end
55
+
56
+ end
57
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: MorseConverter
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Evin Ugur
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2013-11-05 00:00:00 -05:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Convert a ruby string into morse code
22
+ email: evinoog96@gmailcom
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - lib/morsecode.rb
31
+ has_rdoc: true
32
+ homepage: https://github.com/evinugur
33
+ licenses: []
34
+
35
+ post_install_message:
36
+ rdoc_options: []
37
+
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ segments:
52
+ - 0
53
+ version: "0"
54
+ requirements: []
55
+
56
+ rubyforge_project:
57
+ rubygems_version: 1.3.6
58
+ signing_key:
59
+ specification_version: 3
60
+ summary: Convert text to morse code
61
+ test_files: []
62
+