Class: Booker::Parsers::Base
- Inherits:
-
Object
- Object
- Booker::Parsers::Base
- Defined in:
- lib/booker/parsers.rb
Overview
Abstract base class for bookmark parsers
Instance Attribute Summary collapse
-
#allurls ⇒ Object
readonly
Returns the value of attribute allurls.
Instance Method Summary collapse
-
#initialize(file_path, search_term) ⇒ Base
constructor
A new instance of Base.
-
#parse ⇒ Object
Abstract method - must be implemented by subclasses.
- #results ⇒ Object
Constructor Details
#initialize(file_path, search_term) ⇒ Base
Returns a new instance of Base.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/booker/parsers.rb', line 21 def initialize(file_path, search_term) @file_path = file_path # escaped, not interpolated: the term comes straight off ARGV, so # `booker "c++"` used to raise RegexpError before it ever searched @searching = Regexp.new(Regexp.escape(search_term), Regexp::IGNORECASE) # an empty term is the completion scripts' bare `booker <TAB>`, and // # matches every field of every bookmark - so answer it once here rather # than running four guaranteed matches per node @match_all = search_term.empty? @allurls = [] end |
Instance Attribute Details
#allurls ⇒ Object (readonly)
Returns the value of attribute allurls.
19 20 21 |
# File 'lib/booker/parsers.rb', line 19 def allurls @allurls end |
Instance Method Details
#parse ⇒ Object
Abstract method - must be implemented by subclasses
34 35 36 |
# File 'lib/booker/parsers.rb', line 34 def parse raise NotImplementedError, "Subclasses must implement parse method" end |
#results ⇒ Object
38 |
# File 'lib/booker/parsers.rb', line 38 def results = @allurls |