Class: Gly::Lister
- Inherits:
-
Object
- Object
- Gly::Lister
- Defined in:
- lib/gly/lister.rb
Defined Under Namespace
Classes: GrepFormat, OverviewFormat
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(files, format = nil) ⇒ Lister
constructor
A new instance of Lister.
- #list(io, errio) ⇒ Object
Constructor Details
#initialize(files, format = nil) ⇒ Lister
Returns a new instance of Lister.
3 4 5 6 7 |
# File 'lib/gly/lister.rb', line 3 def initialize(files, format=nil) @files = files @error = false @format = find_formatter(format || :grep) end |
Instance Method Details
#error? ⇒ Boolean
26 27 28 |
# File 'lib/gly/lister.rb', line 26 def error? @error end |
#list(io, errio) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gly/lister.rb', line 9 def list(io, errio) @files.each do |f| begin document = Parser.new.parse(f) rescue SystemCallError => err # Errno::WHATEVER errio.puts "Cannot read file '#{f}': #{err.}" @error = true next end io.puts @format.file(f) document.scores.each do |s| io.puts @format.score(s) end end end |