Class: Biblionet::Extractors::PublisherExtractor
- Defined in:
- lib/bookshark/extractors/publisher_extractor.rb
Instance Attribute Summary collapse
-
#publisher ⇒ Object
readonly
Returns the value of attribute publisher.
Attributes inherited from Base
#biblionet_id, #filepath, #page, #url
Instance Method Summary collapse
- #extract_publisher(biblionet_id = @biblionet_id, publisher_page = @page) ⇒ Object
-
#initialize(uri = nil) ⇒ PublisherExtractor
constructor
A new instance of PublisherExtractor.
- #load_and_extract_publisher(uri = nil) ⇒ Object
Methods inherited from Base
#decode_text, decode_text, #load_page, #load_page_from_file, #load_page_from_url, #present?, #save_page
Methods included from FileManager
#list_directories, #list_files, #save_to
Constructor Details
#initialize(uri = nil) ⇒ PublisherExtractor
Returns a new instance of PublisherExtractor.
12 13 14 15 |
# File 'lib/bookshark/extractors/publisher_extractor.rb', line 12 def initialize(uri=nil) super(uri) extract_publisher unless uri.nil? or @page.nil? end |
Instance Attribute Details
#publisher ⇒ Object (readonly)
Returns the value of attribute publisher.
10 11 12 |
# File 'lib/bookshark/extractors/publisher_extractor.rb', line 10 def publisher @publisher end |
Instance Method Details
#extract_publisher(biblionet_id = @biblionet_id, publisher_page = @page) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bookshark/extractors/publisher_extractor.rb', line 23 def extract_publisher(biblionet_id=@biblionet_id, publisher_page=@page) puts "Extracting publisher: #{biblionet_id}" page = PublisherDataExtractor.new(publisher_page) return nil if page.nodeset.nil? headquarters = page.headquarters bookstores = page.bookstores bookstores['Έδρα'] = headquarters unless headquarters.all? {|k,v| v.nil? or v.empty?} publisher_hash = {} publisher_hash[:name] = page.name publisher_hash[:owner] = page.owner publisher_hash[:bookstores] = bookstores publisher_hash[:b_id] = biblionet_id return @publisher = publisher_hash end |
#load_and_extract_publisher(uri = nil) ⇒ Object
18 19 20 21 |
# File 'lib/bookshark/extractors/publisher_extractor.rb', line 18 def load_and_extract_publisher(uri=nil) load_page(uri) extract_publisher unless uri.nil? or @page.nil? end |