Module: InputStream
- Defined in:
- lib/input_stream_module/input_stream.rb
Class Method Summary collapse
Class Method Details
.analyze(input) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/input_stream_module/input_stream.rb', line 3 def self.analyze(input) if input.empty? self.prompt("--- Please input your text below ----") self.get_input else self.read_file(input) end end |
.get_input ⇒ Object
16 17 18 |
# File 'lib/input_stream_module/input_stream.rb', line 16 def self.get_input STDIN.gets end |
.prompt(string) ⇒ Object
12 13 14 |
# File 'lib/input_stream_module/input_stream.rb', line 12 def self.prompt(string) puts string end |
.read_file(input) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/input_stream_module/input_stream.rb', line 20 def self.read_file(input) if input.detect { |path| File.file?(path) == false } raise LoadError, "File not found: Please try again." exit 2 else ARGF.read end end |