Class: Evilution::CLI::Parser::StdinReader Private

Inherits:
Object
  • Object
show all
Defined in:
lib/evilution/cli/parser/stdin_reader.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: Result

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io, existing_files:) ⇒ StdinReader

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

#callObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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
  parsed_paths = Evilution::CLI::Parser::FileArgs.parse(lines)
  Result.new(parsed_paths.files, parsed_paths.ranges, nil)
end