Class: Nosy::Searcher

Inherits:
Object
  • Object
show all
Defined in:
lib/nosy/searcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Searcher

Returns a new instance of Searcher.



6
7
8
# File 'lib/nosy/searcher.rb', line 6

def initialize( file )
  @texts = Parser.new.parse( file )
end

Instance Attribute Details

#textsObject

Returns the value of attribute texts.



4
5
6
# File 'lib/nosy/searcher.rb', line 4

def texts
  @texts
end

Instance Method Details

#search(filters = {}) ⇒ Object



10
11
12
13
14
15
# File 'lib/nosy/searcher.rb', line 10

def search(filters={})

  @texts.select do |text|
    filters.all?{ |key, value| key == :date ? filter_dates(key, value, text) : text[key] == value }
  end
end