Class: Soup::Backends::MultiSoup

Inherits:
Base
  • Object
show all
Defined in:
lib/soup/backends/multi_soup.rb

Instance Method Summary collapse

Methods inherited from Base

#find

Constructor Details

#initialize(*backends) ⇒ MultiSoup

Returns a new instance of MultiSoup.



4
5
6
# File 'lib/soup/backends/multi_soup.rb', line 4

def initialize(*backends)
  @backends = backends
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/soup/backends/multi_soup.rb', line 12

def method_missing(*args)
  @backends.each do |backend|
    if backend.respond_to?(args.first)
      result = backend.__send__(*args)
      return result if result
    end
  end
  nil
end

Instance Method Details

#all_snipsObject



26
27
28
# File 'lib/soup/backends/multi_soup.rb', line 26

def all_snips
  @backends.map { |b| b.all_snips }.flatten
end

#prepareObject



8
9
10
# File 'lib/soup/backends/multi_soup.rb', line 8

def prepare
  @backends.each { |b| b.prepare }
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/soup/backends/multi_soup.rb', line 22

def respond_to?(method)
  super || @backends.inject(false) { |ok, b| ok || b.respond_to?(method) }
end