Class: Common

Inherits:
Formatted show all
Defined in:
lib/glark/output/common.rb

Direct Known Subclasses

BinaryFileSummary, Count, FileNameOnly, Lines

Instance Attribute Summary

Attributes inherited from Formatted

#formatted

Attributes inherited from Results

#count

Instance Method Summary collapse

Methods inherited from Formatted

#get_line_to_print

Methods inherited from Results

#matched?

Constructor Details

#initialize(file, spec) ⇒ Common

Returns a new instance of Common.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/glark/output/common.rb', line 11

def initialize file, spec
  super()

  @file = file
  @invert_match = spec.invert_match
  @label = spec.label
  @match_limit = spec.match_limit
  @out = spec.out
  @show_file_name = spec.show_file_names
  @show_line_numbers = spec.show_line_numbers
end

Instance Method Details

#add_match(startline, endline) ⇒ Object



35
36
37
# File 'lib/glark/output/common.rb', line 35

def add_match startline, endline
  super()
end

#at_match_limit?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/glark/output/common.rb', line 27

def at_match_limit?
  @match_limit && @count >= @match_limit
end

#display_matches?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/glark/output/common.rb', line 23

def display_matches?
  true
end

#displayed_nameObject



31
32
33
# File 'lib/glark/output/common.rb', line 31

def displayed_name
  @label || @file.fname
end

#process_match(startline, endline, fromline, toline) ⇒ Object



39
40
41
42
# File 'lib/glark/output/common.rb', line 39

def process_match startline, endline, fromline, toline
  add_match startline, endline
  return at_match_limit?
end