Class: Sovren::Publication

Inherits:
Object
  • Object
show all
Defined in:
lib/sovren/publication.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#abstractObject

Returns the value of attribute abstract.



3
4
5
# File 'lib/sovren/publication.rb', line 3

def abstract
  @abstract
end

#commentsObject

Returns the value of attribute comments.



3
4
5
# File 'lib/sovren/publication.rb', line 3

def comments
  @comments
end

#conference_dateObject

Returns the value of attribute conference_date.



3
4
5
# File 'lib/sovren/publication.rb', line 3

def conference_date
  @conference_date
end

#conference_locationObject

Returns the value of attribute conference_location.



3
4
5
# File 'lib/sovren/publication.rb', line 3

def conference_location
  @conference_location
end

Returns the value of attribute copyright_date.



3
4
5
# File 'lib/sovren/publication.rb', line 3

def copyright_date
  @copyright_date
end

Returns the value of attribute copyright_text.



3
4
5
# File 'lib/sovren/publication.rb', line 3

def copyright_text
  @copyright_text
end

#editionObject

Returns the value of attribute edition.



3
4
5
# File 'lib/sovren/publication.rb', line 3

def edition
  @edition
end

#event_nameObject

Returns the value of attribute event_name.



3
4
5
# File 'lib/sovren/publication.rb', line 3

def event_name
  @event_name
end

#isbnObject

Returns the value of attribute isbn.



3
4
5
# File 'lib/sovren/publication.rb', line 3

def isbn
  @isbn
end

#issueObject

Returns the value of attribute issue.



3
4
5
# File 'lib/sovren/publication.rb', line 3

def issue
  @issue
end

#journal_or_serial_nameObject

Returns the value of attribute journal_or_serial_name.



3
4
5
# File 'lib/sovren/publication.rb', line 3

def journal_or_serial_name
  @journal_or_serial_name
end

#number_of_pagesObject

Returns the value of attribute number_of_pages.



3
4
5
# File 'lib/sovren/publication.rb', line 3

def number_of_pages
  @number_of_pages
end

#page_numberObject

Returns the value of attribute page_number.



3
4
5
# File 'lib/sovren/publication.rb', line 3

def page_number
  @page_number
end

#publication_dateObject

Returns the value of attribute publication_date.



3
4
5
# File 'lib/sovren/publication.rb', line 3

def publication_date
  @publication_date
end

#publisher_locationObject

Returns the value of attribute publisher_location.



3
4
5
# File 'lib/sovren/publication.rb', line 3

def publisher_location
  @publisher_location
end

#publisher_nameObject

Returns the value of attribute publisher_name.



3
4
5
# File 'lib/sovren/publication.rb', line 3

def publisher_name
  @publisher_name
end

#roleObject

Returns the value of attribute role.



3
4
5
# File 'lib/sovren/publication.rb', line 3

def role
  @role
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/sovren/publication.rb', line 3

def title
  @title
end

#typeObject

Returns the value of attribute type.



3
4
5
# File 'lib/sovren/publication.rb', line 3

def type
  @type
end

#volumeObject

Returns the value of attribute volume.



3
4
5
# File 'lib/sovren/publication.rb', line 3

def volume
  @volume
end

Class Method Details

.parse(publications) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sovren/publication.rb', line 5

def self.parse(publications)
  return Array.new if publications.nil?
  result = publications.css('Article,Book,ConferencePaper,OtherPublication').collect do |item|
    c = Publication.new
    c.type = item.name == "OtherPublication" ? item['type'] : item.name
    c.title = item.css('Title').text
    c.role = item.css('Name').first['role'] rescue nil
    c.publication_date = item.css('PublicationDate').css('YearMonth,Year').first.text rescue nil
    c.journal_or_serial_name = item.css('JournalOrSerialName').text
    c.volume = item.css('Volume').text
    c.issue = item.css('Issue').text
    c.page_number = item.css('PageNumber').text
    c.abstract = item.css('Abstract').text
    c.copyright_date = item.css('Copyright CopyrightDates OriginalDate Year, Copyright CopyrightDates OriginalDate YearMonth').first.text rescue nil
    c.copyright_text = item.css('Copyright CopyrightText').first.text rescue nil
    c.edition = item.css('Edition').text
    c.isbn = item.css('ISBN').text
    c.publisher_name = item.css('PublisherName').text
    c.publisher_location = item.css('PublisherLocation').text
    c.event_name = item.css('EventName').text
    c.conference_date = Date.parse(item.css('ConferenceDate AnyDate').text) rescue nil
    c.conference_location = item.css('ConferenceLocation').text
    c.comments = item.css('Comments').text
    c.number_of_pages = item.css('NumberOfPages').text.to_i rescue nil
    c
  end
  result
end