Module: GroceryList
- Defined in:
- lib/grocery_list.rb,
lib/grocery_list/item.rb,
lib/grocery_list/version.rb,
lib/grocery_list/item_parser.rb,
lib/grocery_list/item_searcher.rb,
lib/grocery_list/item_parsers/file_item_parser.rb,
lib/grocery_list/item_parsers/json_item_parser.rb,
lib/grocery_list/item_parsers/string_item_parser.rb,
lib/grocery_list/item_searchers/iga_item_searcher.rb
Defined Under Namespace
Classes: AbstractItemParser, AbstractSearcher, FileItemParser, IGASearcher, Item, JsonItemParser, StringItemParser
Constant Summary collapse
- VERSION =
"0.0.4"
- @@source_type_tests =
{ :is_a_path? => ->(s) { s.is_a? String and File.readable? s }, :is_json_array? => ->(s) { s.start_with? '[' }, :is_a_string? => ->(s) { s.is_a? String and not File.readable? s}, }
- @@searchers =
{ :is_a_path? => ->(s) { FileItemParser.read(s) }, :is_json_array? => ->(s) { JsonItemParser.read(s) }, :is_a_string? => ->(s) { StringItemParser.read(s) }, }
Class Attribute Summary collapse
-
.items ⇒ Object
readonly
Returns the value of attribute items.
-
.searcher ⇒ Object
readonly
Returns the value of attribute searcher.
Class Method Summary collapse
Class Attribute Details
.items ⇒ Object (readonly)
Returns the value of attribute items.
5 6 7 |
# File 'lib/grocery_list.rb', line 5 def items @items end |
.searcher ⇒ Object (readonly)
Returns the value of attribute searcher.
5 6 7 |
# File 'lib/grocery_list.rb', line 5 def searcher @searcher end |
Class Method Details
.search_all(items_source, searcher = IGASearcher.new) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/grocery_list.rb', line 18 def search_all(items_source, searcher = IGASearcher.new) validate_input(items_source, searcher) @items = items_from_source(items_source) @searcher = searcher @items.each do |item| # For some odd reason, google chrome (and other browsers?) don't let # you open more than three tabs very quickly. So this sleep 0.2 works around # it. Not really sure what else I could do. It's ugly but it works... sleep 0.2 @searcher.search(item) end end |