m0rse_c0de 0.3.5 → 0.3.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 +4 -4
- data/README.md +10 -6
- data/lib/hashes/hashes.rb +1 -14
- data/lib/m0rse.rb +20 -18
- data/lib/sound/sound.rb +20 -8
- data/lib/teacher/hangman.rb +0 -2
- data/lib/teacher/teacher.rb +34 -34
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb38c6816fa1eef56c647bcdda493cb1f9be0a47aa35311efa32ec763a23dc79
|
4
|
+
data.tar.gz: 0c64785f5a54ab08ce269c4b9a51d6c0405eaa4692243402311301f72cd21429
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 960618fbc70ea05cf422a1ca0eb7eda1d3840b5cb1ef147e6d5e299c7c11dfd4b51d348a1e67add3ef995164f325d19a3edcee9f8dc758216741ba1e6b8932db
|
7
|
+
data.tar.gz: 657fb662dc56ede3929250133c86be7156ed02db7a137ac47301f932f78752b0c7f5aefdba999dcf62961d9acffc49eb4b98db5b75bc2c10747a6414dcd6afd8
|
data/README.md
CHANGED
@@ -2,17 +2,21 @@
|
|
2
2
|
|
3
3
|
## Usage
|
4
4
|
```
|
5
|
-
|
6
|
-
|
5
|
+
require 'm0rse'
|
6
|
+
|
7
|
+
include M0rse
|
7
8
|
|
8
9
|
```
|
9
10
|
|
10
|
-
call ```Morse.
|
11
|
+
call ```Morse.teacher``` contains small games that you can play from the terminalto help you learn morse code:
|
12
|
+
|
13
|
+
```Morse.teacher.hangman```
|
14
|
+
```Morse.teacher.practice```
|
15
|
+
|
16
|
+
|
11
17
|
call ```Morse.blink(text)``` to make your terminal blink in morse code (windows only)
|
12
|
-
call ```Morse.play(text)``` to make your computer play morse code
|
18
|
+
call ```Morse.play(text)``` to make your computer play morse code
|
13
19
|
|
14
20
|
other methods are self-explanatory.
|
15
21
|
|
16
|
-
## Notes
|
17
22
|
|
18
|
-
Please notify me if you find any bugs, I am trying to make something useful.
|
data/lib/hashes/hashes.rb
CHANGED
@@ -18,20 +18,7 @@ module Translation
|
|
18
18
|
'0' => '-----', ', ' => '--..--', '.' => '.-.-.-',
|
19
19
|
'?' => '..--..', '/' => '-..-.', '-' => '-....-', ' ' => '\\'}
|
20
20
|
|
21
|
-
@@morsetoascii =
|
22
|
-
'-.-.' => 'c', '-..' => 'd', '.' => 'e',
|
23
|
-
'..-.' => 'f', '--.' => 'g', '....' => 'h',
|
24
|
-
'..' => 'i', '.---' => 'j', '-.-' => 'k',
|
25
|
-
'.-..' => 'l', '--' => 'm', '-.' => 'n',
|
26
|
-
'---' => 'o', '.--.' => 'p', '--.-' => 'q',
|
27
|
-
'.-.' => 'r', '...' => 's', '-' => 't',
|
28
|
-
'..-' => 'u', '...-' => 'v', '.--' => 'w',
|
29
|
-
'-..-'=> 'x', '-.--' => 'y', '--..' => 'z',
|
30
|
-
'.----' => '1', '..---' => '2', '...--' => '3',
|
31
|
-
'....-' => '4', '.....' => '5', '-....' => '6',
|
32
|
-
'--...' => '7', '---..' => '8', '----.' => '9',
|
33
|
-
'-----' => '0', '--..--' => ',', '.-.-.-' => '.',
|
34
|
-
'..--..' => '?', '-..-.' => '/', '-....-' => '-', '\\' => ' '}
|
21
|
+
@@morsetoascii = @@asciitomorse.invert
|
35
22
|
|
36
23
|
|
37
24
|
end
|
data/lib/m0rse.rb
CHANGED
@@ -12,8 +12,9 @@ include Beeper
|
|
12
12
|
|
13
13
|
module M0rse
|
14
14
|
|
15
|
+
@@teacher = Teacher
|
16
|
+
|
15
17
|
class Morse
|
16
|
-
|
17
18
|
def self.text_to_morse(text_)
|
18
19
|
morse_ = []
|
19
20
|
text_.downcase!
|
@@ -64,50 +65,51 @@ module M0rse
|
|
64
65
|
text_ = file_.readlines.map(&:chomp).join()
|
65
66
|
result_ = self.text_to_morse(text_)
|
66
67
|
file_.close()
|
67
|
-
File.open("#{filename_}-Morsed", "w")
|
68
|
+
new_file = File.open("#{filename_}-Morsed", "w")
|
69
|
+
File.write(new_file, result_)
|
68
70
|
end
|
69
71
|
|
70
72
|
def self.blink(text_)
|
71
73
|
morse_ = self.text_to_morse(text_)
|
72
|
-
for
|
73
|
-
if
|
74
|
+
for char in morse_.split(//)
|
75
|
+
if char == '.'
|
74
76
|
system('color 70')
|
75
77
|
sleep(0.01)
|
76
78
|
system('color 07')
|
77
|
-
elsif
|
79
|
+
elsif char == '-'
|
78
80
|
system('color 70')
|
79
81
|
sleep(0.2)
|
80
82
|
system('color 07')
|
81
|
-
elsif
|
83
|
+
elsif char == ' '
|
82
84
|
sleep(0.3)
|
83
|
-
elsif
|
85
|
+
elsif char == '\\'
|
84
86
|
sleep(0.7)
|
85
87
|
end
|
86
88
|
end; "completed"
|
87
89
|
end
|
88
90
|
|
89
91
|
|
90
|
-
def self.play(text_)
|
92
|
+
def self.play(text_, speed=1)
|
91
93
|
morse_ = self.text_to_morse(text_)
|
92
94
|
begin
|
93
|
-
for
|
94
|
-
if
|
95
|
+
for char in morse_.split(//)
|
96
|
+
if char == '.'
|
95
97
|
Beeper.dit
|
96
|
-
elsif
|
98
|
+
elsif char == '-'
|
97
99
|
Beeper.dah
|
98
|
-
elsif
|
99
|
-
sleep(0.375)
|
100
|
-
elsif
|
101
|
-
sleep(0.875)
|
100
|
+
elsif char == ' '
|
101
|
+
sleep(0.375*speed)
|
102
|
+
elsif char == '\\'
|
103
|
+
sleep(0.875*speed)
|
102
104
|
end
|
103
105
|
end; "completed"
|
104
106
|
rescue
|
105
|
-
puts "
|
107
|
+
puts "something went wrong..."
|
106
108
|
end
|
107
109
|
end
|
108
110
|
|
109
|
-
def self.
|
110
|
-
|
111
|
+
def self.teacher
|
112
|
+
@@teacher
|
111
113
|
end
|
112
114
|
|
113
115
|
end
|
data/lib/sound/sound.rb
CHANGED
@@ -2,17 +2,29 @@ begin
|
|
2
2
|
require 'win32/sound'
|
3
3
|
|
4
4
|
include Win32
|
5
|
+
|
6
|
+
module Beeper
|
7
|
+
def dit
|
8
|
+
Sound.play("#{__dir__}/beeps/dit.wav")
|
9
|
+
end
|
10
|
+
|
11
|
+
def dah
|
12
|
+
Sound.play("#{__dir__}/beeps/dah.wav")
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
5
17
|
rescue LoadError
|
18
|
+
module Beeper
|
19
|
+
def dit
|
20
|
+
system("play #{__dir__}/beeps/dit.wav -q -t alsa")
|
21
|
+
end
|
6
22
|
|
7
|
-
|
23
|
+
def dah
|
24
|
+
system("play #{__dir__}/beeps/dah.wav -q -t alsa")
|
25
|
+
end
|
8
26
|
|
9
|
-
module Beeper
|
10
|
-
def dit
|
11
|
-
Sound.play("#{__dir__}/beeps/dit.wav")
|
12
27
|
end
|
13
|
-
|
14
|
-
def dah
|
15
|
-
Sound.play("#{__dir__}/beeps/dah.wav")
|
16
|
-
end
|
17
28
|
|
18
29
|
end
|
30
|
+
|
data/lib/teacher/hangman.rb
CHANGED
data/lib/teacher/teacher.rb
CHANGED
@@ -2,13 +2,40 @@
|
|
2
2
|
module Te4cher
|
3
3
|
class Teacher
|
4
4
|
|
5
|
-
|
5
|
+
@@word_list = ['Ruby', 'Red', 'Awesome', 'Burzum',
|
6
|
+
'Help', 'Blood', 'Emergency', 'Death',
|
7
|
+
'Morse', 'SOS', 'SQL', 'Wreck', 'Ship',
|
8
|
+
'You', 'Us', 'America', 'Boat', 'Hello',
|
9
|
+
'Amazed', 'Python', 'Life', 'acme',
|
10
|
+
'antiseptically', 'boudoir', 'cesium', 'circumscribing',
|
11
|
+
'collegians', 'confessionals', 'erectly', 'finagler',
|
12
|
+
'hostelries', 'howdah', 'impetigo', 'lampposts', 'lisle',
|
13
|
+
'mestizos', 'overcooked', 'slippage', 'slouchiest',
|
14
|
+
'strumpet', 'terabyte', 'transfiguration', 'twill',
|
15
|
+
'undersold', 'unsheathed', 'whelps', 'adlumidine',
|
16
|
+
'alinasal', 'aramina', 'begreen', 'bembixes',
|
17
|
+
'boundly', 'cannibalean', 'chondrinous', 'colickiest',
|
18
|
+
'cullas', 'hartake', 'interchangings', 'marquito',
|
19
|
+
'miscegenationists', 'peremption', 'quesitive', 'ragnarok',
|
20
|
+
'reconciliated', 'sepsine', 'sickless', 'sigillaria',
|
21
|
+
'staphyledema', 'undelible', 'unruth', 'yaourti',
|
22
|
+
'avoid', 'bottle', 'briefly', 'bug',
|
23
|
+
'dedicated', 'establish', 'everything', 'goes',
|
24
|
+
'harm', 'inferior', 'killed', 'leader',
|
25
|
+
'noticed', 'quicker', 'recovered', 'reflects',
|
26
|
+
'retain', 'self', 'should', 'signal',
|
27
|
+
'simultaneously', 'stayed', 'tomorrow', 'virtue',
|
28
|
+
'weird', 'adlumidine', 'alinasal', 'aramina',
|
29
|
+
'begreen', 'bembixes', 'boundly', 'cannibalean',
|
30
|
+
'chondrinous', 'colickiest', 'cullas', 'hartake',
|
31
|
+
'interchangings', 'marquito', 'miscegenationists', 'peremption',
|
32
|
+
'quesitive', 'ragnarok', 'reconciliated', 'sepsine',
|
33
|
+
'sickless', 'sigillaria', 'staphyledema', 'undelible', 'unruth', 'yaourti'] #todo: complete
|
6
34
|
|
7
|
-
def self.start_practice
|
8
|
-
puts "PRACTICE MODE STARTED"
|
9
35
|
|
36
|
+
def self.practice
|
10
37
|
while true
|
11
|
-
random_word =
|
38
|
+
random_word = @@word_list.sample.upcase!
|
12
39
|
correct_answer = Morse.text_to_morse(random_word)
|
13
40
|
puts "translate ---> #{random_word}"
|
14
41
|
print 'Your answer: '
|
@@ -17,50 +44,23 @@ module Te4cher
|
|
17
44
|
puts 'Correct! Moving to the next word...'
|
18
45
|
sleep(2)
|
19
46
|
else
|
20
|
-
puts "Wrong! The correct answer was: #{correct_answer}
|
47
|
+
puts "Wrong! The correct answer was: #{correct_answer} \nmoving to the next word..."
|
21
48
|
sleep(2)
|
22
49
|
end
|
23
50
|
end
|
24
51
|
end
|
25
52
|
|
26
|
-
def self.
|
27
|
-
Hangman.choose_word(
|
53
|
+
def self.hangman
|
54
|
+
Hangman.choose_word(@@word_list)
|
28
55
|
Hangman.main
|
29
56
|
end
|
30
57
|
|
31
58
|
def self.show_hashes
|
32
|
-
print @word_list
|
33
59
|
for char, morse in @@asciitomorse
|
34
60
|
print char, ' --> ', morse, ' '
|
35
61
|
end; 'Morse Alphabet'
|
36
62
|
end
|
37
|
-
|
38
|
-
|
39
|
-
def self.main
|
40
|
-
greeting = '''
|
41
|
-
|
42
|
-
Welcome to teaching mode! If you want to practice: input PRACTICE,
|
43
|
-
if you want to view the Morse alphabet input ALPHABET,
|
44
|
-
if you want to play hangman in Morse; input HANGMAN.
|
45
|
-
|
46
|
-
'''
|
47
|
-
|
48
|
-
puts greeting
|
49
|
-
|
50
|
-
@choice = gets.chomp
|
51
|
-
|
52
|
-
if @choice == 'PRACTICE'
|
53
|
-
self.start_practice
|
54
|
-
|
55
|
-
elsif @choice == 'ALPHABET'
|
56
|
-
self.show_hashes
|
57
|
-
elsif @choice == 'HANGMAN'
|
58
|
-
self.start_hangman
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
63
|
end
|
63
|
-
|
64
64
|
end
|
65
65
|
|
66
66
|
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: m0rse_c0de
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Burzum
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: win32-sound
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.6.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.6.2
|
27
27
|
description:
|
@@ -61,6 +61,6 @@ rubygems_version: 3.1.2
|
|
61
61
|
signing_key:
|
62
62
|
specification_version: 4
|
63
63
|
summary: A gem for translation from hex, binary, text to morse and vice versa; it
|
64
|
-
additionally can teach you Morse, play
|
65
|
-
Morse and it can blink in Morse.
|
64
|
+
additionally can teach you Morse, play text to Morse (on linux requires SoX), translate
|
65
|
+
a file to Morse and it can blink in Morse.
|
66
66
|
test_files: []
|