Class: Booker::Parsers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/booker/parsers.rb

Overview

Abstract base class for bookmark parsers

Direct Known Subclasses

Chrome, Firefox, Safari

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#allurlsObject (readonly)

Returns the value of attribute allurls.



19
20
21
# File 'lib/booker/parsers.rb', line 19

def allurls
  @allurls
end

Instance Method Details

#parseObject

Abstract method - must be implemented by subclasses

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/booker/parsers.rb', line 34

def parse
  raise NotImplementedError, "Subclasses must implement parse method"
end

#resultsObject



38
# File 'lib/booker/parsers.rb', line 38

def results = @allurls