Class: Vessel::Loader
- Inherits:
-
Object
- Object
- Vessel::Loader
- Defined in:
- lib/vessel/loader.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#crawlers ⇒ Object
readonly
Returns the value of attribute crawlers.
Instance Method Summary collapse
- #find_crawler(name) ⇒ Object
-
#initialize ⇒ Loader
constructor
A new instance of Loader.
- #list_crawlers ⇒ Object
- #load_crawler(name) ⇒ Object
- #load_crawlers ⇒ Object
- #register(name, klass) ⇒ Object
- #templator ⇒ Object
Constructor Details
#initialize ⇒ Loader
Returns a new instance of Loader.
7 8 9 |
# File 'lib/vessel/loader.rb', line 7 def initialize @crawlers = {} end |
Instance Attribute Details
#crawlers ⇒ Object (readonly)
Returns the value of attribute crawlers.
5 6 7 |
# File 'lib/vessel/loader.rb', line 5 def crawlers @crawlers end |
Instance Method Details
#find_crawler(name) ⇒ Object
28 29 30 |
# File 'lib/vessel/loader.rb', line 28 def find_crawler(name) @crawlers[name] end |
#list_crawlers ⇒ Object
32 33 34 |
# File 'lib/vessel/loader.rb', line 32 def list_crawlers @crawlers.keys.sort end |
#load_crawler(name) ⇒ Object
19 20 21 22 |
# File 'lib/vessel/loader.rb', line 19 def load_crawler(name) path = File.("crawlers/#{name}.rb") require(path) if File.exist?(path) end |
#load_crawlers ⇒ Object
15 16 17 |
# File 'lib/vessel/loader.rb', line 15 def load_crawlers Dir["crawlers/**/*.rb"].each { |file| require(file) } end |
#register(name, klass) ⇒ Object
24 25 26 |
# File 'lib/vessel/loader.rb', line 24 def register(name, klass) @crawlers.merge!(name => klass) end |
#templator ⇒ Object
11 12 13 |
# File 'lib/vessel/loader.rb', line 11 def templator Templator end |