Class: Trifle::Logs::Operations::Searcher
- Inherits:
-
Object
- Object
- Trifle::Logs::Operations::Searcher
- Defined in:
- lib/trifle/logs/operations/searcher.rb
Instance Attribute Summary collapse
-
#max_loc ⇒ Object
readonly
Returns the value of attribute max_loc.
-
#min_loc ⇒ Object
readonly
Returns the value of attribute min_loc.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize(**keywords) ⇒ Searcher
constructor
A new instance of Searcher.
- #next ⇒ Object
- #perform ⇒ Object
- #prev ⇒ Object
Constructor Details
#initialize(**keywords) ⇒ Searcher
Returns a new instance of Searcher.
9 10 11 12 13 14 15 |
# File 'lib/trifle/logs/operations/searcher.rb', line 9 def initialize(**keywords) @namespace = keywords.fetch(:namespace) @pattern = keywords.fetch(:pattern) @config = keywords[:config] @min_loc = keywords[:min_loc] @max_loc = keywords[:max_loc] end |
Instance Attribute Details
#max_loc ⇒ Object (readonly)
Returns the value of attribute max_loc.
7 8 9 |
# File 'lib/trifle/logs/operations/searcher.rb', line 7 def max_loc @max_loc end |
#min_loc ⇒ Object (readonly)
Returns the value of attribute min_loc.
7 8 9 |
# File 'lib/trifle/logs/operations/searcher.rb', line 7 def min_loc @min_loc end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
7 8 9 |
# File 'lib/trifle/logs/operations/searcher.rb', line 7 def namespace @namespace end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
7 8 9 |
# File 'lib/trifle/logs/operations/searcher.rb', line 7 def pattern @pattern end |
Instance Method Details
#config ⇒ Object
17 18 19 |
# File 'lib/trifle/logs/operations/searcher.rb', line 17 def config @config || Trifle::Logs.default end |
#next ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/trifle/logs/operations/searcher.rb', line 42 def next return Trifle::Logs::Result.new if @max_loc.nil? result = config.driver.search( namespace: namespace, pattern: pattern, file_loc: @max_loc, direction: :next ) @max_loc = result.max_loc result end |
#perform ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/trifle/logs/operations/searcher.rb', line 21 def perform result = config.driver.search( namespace: namespace, pattern: pattern ) @min_loc = result.min_loc @max_loc = result.max_loc result end |
#prev ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/trifle/logs/operations/searcher.rb', line 30 def prev return Trifle::Logs::Result.new if @min_loc.nil? result = config.driver.search( namespace: namespace, pattern: pattern, file_loc: @min_loc, direction: :prev ) @min_loc = result.min_loc result end |