Class: Catalog::DrawerMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/catalog/services/drawer_matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document:) ⇒ DrawerMatcher

Returns a new instance of DrawerMatcher.



6
7
8
# File 'lib/catalog/services/drawer_matcher.rb', line 6

def initialize(document:)
  @document = document
end

Instance Attribute Details

#drawerObject (readonly)

Accessors



4
5
6
# File 'lib/catalog/services/drawer_matcher.rb', line 4

def drawer
  @drawer
end

Instance Method Details

#match?Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/catalog/services/drawer_matcher.rb', line 10

def match?
  Catalog::Drawer.all.each do |drawer|
    document_where_froms.each do |url|
      @drawer = drawer if /#{drawer.rule}/.match(url)

      break if @drawer
    end

    break if @drawer
  end

  !@drawer.nil?
end