class Biblionet::Extractors::AuthorExtractor
Attributes
Public Class Methods
new(uri=nil)
click to toggle source
Calls superclass method
# File lib/bookshark/extractors/author_extractor.rb, line 12 def initialize(uri=nil) super(uri) extract_author unless uri.nil? or @page.nil? end
Public Instance Methods
split_name(fullname)
click to toggle source
# File lib/bookshark/extractors/author_extractor.rb, line 57 def split_name(fullname) #mathes digits-digits or digits- in text like: Tolkien, John Ronald Reuel, 1892-1973 years_re = /\d+-\d*/ parts = fullname.split(',').map(&:strip) identity = {} identity[:lastname] = parts[0] if parts.length == 2 if parts[1] =~ years_re identity[:extra_info] = parts[1] else identity[:firstname] = parts[1] end elsif parts.length == 3 identity[:firstname] = parts[1] identity[:extra_info] = parts[2] end return identity end