Class: Ace::Search::Models::SearchOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/search/models/search_options.rb

Overview

SearchOptions encapsulates all search configuration parameters This is a model - pure data structure

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern, **options) ⇒ SearchOptions

Returns a new instance of SearchOptions.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ace/search/models/search_options.rb', line 16

def initialize(pattern, **options)
  @pattern = pattern
  @type = options[:type] || :auto
  @case_insensitive = options[:case_insensitive] || false
  @whole_word = options[:whole_word] || false
  @multiline = options[:multiline] || false
  @context = options[:context] || 0
  @before_context = options[:before_context]
  @after_context = options[:after_context]
  @glob = options[:glob]
  @exclude = options[:exclude] || []
  @include = options[:include] || []
  @max_results = options[:max_results]
  @hidden = options[:hidden] || false
  @files_with_matches = options[:files_with_matches] || false
  @scope = options[:scope]
  @since = options[:since]
  @before = options[:before]
  @format = options[:format] || :text
  @interactive = options[:interactive] || false
  @preset = options[:preset]
end

Instance Attribute Details

#after_contextObject

Returns the value of attribute after_context.



9
10
11
# File 'lib/ace/search/models/search_options.rb', line 9

def after_context
  @after_context
end

#beforeObject

Returns the value of attribute before.



9
10
11
# File 'lib/ace/search/models/search_options.rb', line 9

def before
  @before
end

#before_contextObject

Returns the value of attribute before_context.



9
10
11
# File 'lib/ace/search/models/search_options.rb', line 9

def before_context
  @before_context
end

#case_insensitiveObject

Returns the value of attribute case_insensitive.



9
10
11
# File 'lib/ace/search/models/search_options.rb', line 9

def case_insensitive
  @case_insensitive
end

#contextObject

Returns the value of attribute context.



9
10
11
# File 'lib/ace/search/models/search_options.rb', line 9

def context
  @context
end

#excludeObject

Returns the value of attribute exclude.



9
10
11
# File 'lib/ace/search/models/search_options.rb', line 9

def exclude
  @exclude
end

#files_with_matchesObject

Returns the value of attribute files_with_matches.



9
10
11
# File 'lib/ace/search/models/search_options.rb', line 9

def files_with_matches
  @files_with_matches
end

#formatObject

Returns the value of attribute format.



9
10
11
# File 'lib/ace/search/models/search_options.rb', line 9

def format
  @format
end

#globObject

Returns the value of attribute glob.



9
10
11
# File 'lib/ace/search/models/search_options.rb', line 9

def glob
  @glob
end

#hiddenObject

Returns the value of attribute hidden.



9
10
11
# File 'lib/ace/search/models/search_options.rb', line 9

def hidden
  @hidden
end

#includeObject

Returns the value of attribute include.



9
10
11
# File 'lib/ace/search/models/search_options.rb', line 9

def include
  @include
end

#interactiveObject

Returns the value of attribute interactive.



9
10
11
# File 'lib/ace/search/models/search_options.rb', line 9

def interactive
  @interactive
end

#max_resultsObject

Returns the value of attribute max_results.



9
10
11
# File 'lib/ace/search/models/search_options.rb', line 9

def max_results
  @max_results
end

#multilineObject

Returns the value of attribute multiline.



9
10
11
# File 'lib/ace/search/models/search_options.rb', line 9

def multiline
  @multiline
end

#patternObject

Returns the value of attribute pattern.



9
10
11
# File 'lib/ace/search/models/search_options.rb', line 9

def pattern
  @pattern
end

#presetObject

Returns the value of attribute preset.



9
10
11
# File 'lib/ace/search/models/search_options.rb', line 9

def preset
  @preset
end

#scopeObject

Returns the value of attribute scope.



9
10
11
# File 'lib/ace/search/models/search_options.rb', line 9

def scope
  @scope
end

#sinceObject

Returns the value of attribute since.



9
10
11
# File 'lib/ace/search/models/search_options.rb', line 9

def since
  @since
end

#typeObject

Returns the value of attribute type.



9
10
11
# File 'lib/ace/search/models/search_options.rb', line 9

def type
  @type
end

#whole_wordObject

Returns the value of attribute whole_word.



9
10
11
# File 'lib/ace/search/models/search_options.rb', line 9

def whole_word
  @whole_word
end

Instance Method Details

#to_hObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/ace/search/models/search_options.rb', line 39

def to_h
  {
    pattern: @pattern,
    type: @type,
    case_insensitive: @case_insensitive,
    whole_word: @whole_word,
    multiline: @multiline,
    context: @context,
    before_context: @before_context,
    after_context: @after_context,
    glob: @glob,
    exclude: @exclude,
    include: @include,
    max_results: @max_results,
    hidden: @hidden,
    files_with_matches: @files_with_matches,
    scope: @scope,
    since: @since,
    before: @before,
    format: @format,
    interactive: @interactive,
    preset: @preset
  }
end