Class: ObfuscatedMorseCode::FileParser
- Inherits:
-
Object
- Object
- ObfuscatedMorseCode::FileParser
- Defined in:
- lib/obfuscated_morse_code/file_parser.rb
Constant Summary collapse
- FileNotFoundError =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
Instance Method Summary collapse
-
#initialize(file_path) ⇒ FileParser
constructor
A new instance of FileParser.
- #parse ⇒ Object
Constructor Details
#initialize(file_path) ⇒ FileParser
Returns a new instance of FileParser.
7 8 9 |
# File 'lib/obfuscated_morse_code/file_parser.rb', line 7 def initialize(file_path) @file_path = file_path end |
Instance Attribute Details
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
3 4 5 |
# File 'lib/obfuscated_morse_code/file_parser.rb', line 3 def file_path @file_path end |
Instance Method Details
#parse ⇒ Object
11 12 13 14 15 |
# File 'lib/obfuscated_morse_code/file_parser.rb', line 11 def parse File.open(file_path).reduce([], &:<<).map(&:strip) rescue Errno::ENOENT raise FileNotFoundError, "Couldn't locate file: '#{file_path}'" end |