Class: Evilution::CLI::Parser::StdinReader
- Inherits:
-
Object
- Object
- Evilution::CLI::Parser::StdinReader
- Defined in:
- lib/evilution/cli/parser/stdin_reader.rb
Defined Under Namespace
Classes: Result
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(io, existing_files:) ⇒ StdinReader
constructor
A new instance of StdinReader.
Constructor Details
#initialize(io, existing_files:) ⇒ StdinReader
Returns a new instance of StdinReader.
12 13 14 15 |
# File 'lib/evilution/cli/parser/stdin_reader.rb', line 12 def initialize(io, existing_files:) @io = io @existing_files = existing_files end |
Class Method Details
.call(io, existing_files:) ⇒ Object
8 9 10 |
# File 'lib/evilution/cli/parser/stdin_reader.rb', line 8 def self.call(io, existing_files:) new(io, existing_files: existing_files).call end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/evilution/cli/parser/stdin_reader.rb', line 17 def call return Result.new([], {}, "--stdin cannot be combined with positional file arguments") if @existing_files.any? lines = [] @io.each_line do |line| line = line.strip lines << line unless line.empty? end files, ranges = Evilution::CLI::Parser::FileArgs.parse(lines) Result.new(files, ranges, nil) end |