Class: FileNameOnly

Inherits:
Common show all
Defined in:
lib/glark/output/file_name_only.rb

Instance Attribute Summary

Attributes inherited from Formatted

#formatted

Attributes inherited from Results

#count

Instance Method Summary collapse

Methods inherited from Common

#add_match, #displayed_name, #process_match

Methods inherited from Formatted

#get_line_to_print

Methods inherited from Results

#add_match, #matched?

Constructor Details

#initialize(fname, spec) ⇒ FileNameOnly

Returns a new instance of FileNameOnly.



8
9
10
11
# File 'lib/glark/output/file_name_only.rb', line 8

def initialize fname, spec
  super
  @write_null = spec.write_null
end

Instance Method Details

#at_match_limit?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/glark/output/file_name_only.rb', line 13

def at_match_limit?
  @count > 0
end

#display_matches?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/glark/output/file_name_only.rb', line 17

def display_matches?
  false
end


21
22
23
24
25
26
27
28
# File 'lib/glark/output/file_name_only.rb', line 21

def print_file_name
  if @write_null
    @out.print @file.fname
    @out.print "\0"
  else
    @out.puts @file.fname
  end
end

#process_end(lnum) ⇒ Object



30
31
32
33
34
# File 'lib/glark/output/file_name_only.rb', line 30

def process_end lnum
  if matched? != @invert_match
    print_file_name
  end
end