Module: Rubber::Ducky
- Defined in:
- lib/rubber-ducky.rb,
lib/rubber-ducky/common.rb,
lib/rubber-ducky/decoder.rb,
lib/rubber-ducky/encoder.rb,
lib/rubber-ducky/version.rb
Defined Under Namespace
Modules: Common, Decoder, Encoder
Constant Summary
collapse
- VERSION =
'1.0'.freeze
Class Method Summary
collapse
Class Method Details
.decode(input_file, output: nil, language: 'us') ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/rubber-ducky.rb', line 19
def self.decode(input_file, output: nil, language: 'us')
content = File.binread(input_file)
decoded = Decoder.decode(content, language)
if output
File.open(output, 'w') { |file| file.write(decoded) }
end
decoded
end
|
.encode(input_file, output: nil, language: 'us') ⇒ Object
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/rubber-ducky.rb', line 8
def self.encode(input_file, output: nil, language: 'us')
content = File.read(input_file)
encoded = Encoder.encode(content, language)
if output
File.open(output, 'wb') do |file|
file.write(encoded)
end
end
encoded
end
|