Class: Grepfruit::Search

Inherits:
Object
  • Object
show all
Defined in:
lib/grepfruit/search.rb

Direct Known Subclasses

CliSearch, ProgrammaticSearch

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, regex:, exclude:, include:, truncate:, search_hidden:, jobs:, json: false, count: false) ⇒ Search

Returns a new instance of Search.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/grepfruit/search.rb', line 11

def initialize(path:, regex:, exclude:, include:, truncate:, search_hidden:, jobs:, json: false, count: false)
  @path = File.expand_path(path)
  @regex = regex
  @exclusions = exclude
  @inclusions = include
  @excluded_lines, @excluded_paths = exclude.partition { _1.split("/").last.include?(":") }
  @truncate = truncate
  @search_hidden = search_hidden
  @jobs = jobs || Etc.nprocessors
  @json = json
  @count = count
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



9
10
11
# File 'lib/grepfruit/search.rb', line 9

def count
  @count
end

#excluded_linesObject (readonly)

Returns the value of attribute excluded_lines.



9
10
11
# File 'lib/grepfruit/search.rb', line 9

def excluded_lines
  @excluded_lines
end

#excluded_pathsObject (readonly)

Returns the value of attribute excluded_paths.



9
10
11
# File 'lib/grepfruit/search.rb', line 9

def excluded_paths
  @excluded_paths
end

#exclusionsObject (readonly)

Returns the value of attribute exclusions.



9
10
11
# File 'lib/grepfruit/search.rb', line 9

def exclusions
  @exclusions
end

#inclusionsObject (readonly)

Returns the value of attribute inclusions.



9
10
11
# File 'lib/grepfruit/search.rb', line 9

def inclusions
  @inclusions
end

#jobsObject (readonly)

Returns the value of attribute jobs.



9
10
11
# File 'lib/grepfruit/search.rb', line 9

def jobs
  @jobs
end

#jsonObject (readonly)

Returns the value of attribute json.



9
10
11
# File 'lib/grepfruit/search.rb', line 9

def json
  @json
end

#pathObject (readonly)

Returns the value of attribute path.



9
10
11
# File 'lib/grepfruit/search.rb', line 9

def path
  @path
end

#regexObject (readonly)

Returns the value of attribute regex.



9
10
11
# File 'lib/grepfruit/search.rb', line 9

def regex
  @regex
end

#search_hiddenObject (readonly)

Returns the value of attribute search_hidden.



9
10
11
# File 'lib/grepfruit/search.rb', line 9

def search_hidden
  @search_hidden
end

#truncateObject (readonly)

Returns the value of attribute truncate.



9
10
11
# File 'lib/grepfruit/search.rb', line 9

def truncate
  @truncate
end