Class: PLOS::Article
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from XmlHelpers
#nodes_to_hash, #parse_node, #tag_value
Constructor Details
#initialize(id, node) ⇒ Article
Returns a new instance of Article.
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/plos/article.rb', line 19
def initialize(id, node)
self.id = id
self.node = node
self.article_title = tag_value(node.search("title-group"), "article-title")
self.journal_title = tag_value(node.search("journal-title-group"), "journal-title")
self.issns = nodes_to_hash(node.search("journal-meta/issn"), "pub-type")
self.journal_ids = nodes_to_hash(node.search("journal-meta/journal-id"), "journal-id-type")
self.article_ids = nodes_to_hash(node.search("article-meta/article-id"), "pub-id-type")
node.search("aff").each do |aff_node|
self.affiliations << PLOS::Affiliation.new(aff_node)
end
node.search("contrib").each do |contrib_node|
self.contributors << PLOS::Contributor.new(contrib_node)
end
node.search("fig").each do |fig_node|
self.figures << PLOS::Figure.new(fig_node)
end
node.search("sec").each do |section_node|
self.sections << PLOS::Section.new(section_node)
end
node.search("ref").each do |ref_node|
self.references << PLOS::Reference.new(ref_node)
end
node.search("named-content").each do |content_node|
type = content_node.attr("content-type")
value = content_node.text
named_content << {:type => type, :value => value}
end
end
|
Instance Attribute Details
#affiliations ⇒ Object
99
100
101
|
# File 'lib/plos/article.rb', line 99
def affiliations
@affiliations ||= []
end
|
#article_ids ⇒ Object
Returns the value of attribute article_ids.
8
9
10
|
# File 'lib/plos/article.rb', line 8
def article_ids
@article_ids
end
|
#article_title ⇒ Object
Returns the value of attribute article_title.
7
8
9
|
# File 'lib/plos/article.rb', line 7
def article_title
@article_title
end
|
#contributors ⇒ Object
103
104
105
|
# File 'lib/plos/article.rb', line 103
def contributors
@contributors ||= []
end
|
107
108
109
|
# File 'lib/plos/article.rb', line 107
def figures
@figures ||= []
end
|
#id ⇒ Object
Returns the value of attribute id.
6
7
8
|
# File 'lib/plos/article.rb', line 6
def id
@id
end
|
#issns ⇒ Object
Returns the value of attribute issns.
11
12
13
|
# File 'lib/plos/article.rb', line 11
def issns
@issns
end
|
#journal_ids ⇒ Object
Returns the value of attribute journal_ids.
10
11
12
|
# File 'lib/plos/article.rb', line 10
def journal_ids
@journal_ids
end
|
#journal_title ⇒ Object
Returns the value of attribute journal_title.
9
10
11
|
# File 'lib/plos/article.rb', line 9
def journal_title
@journal_title
end
|
#named_content ⇒ Object
119
120
121
|
# File 'lib/plos/article.rb', line 119
def named_content
@named_content ||= []
end
|
#node ⇒ Object
Returns the value of attribute node.
5
6
7
|
# File 'lib/plos/article.rb', line 5
def node
@node
end
|
#references ⇒ Object
111
112
113
|
# File 'lib/plos/article.rb', line 111
def references
@references ||= []
end
|
#sections ⇒ Object
115
116
117
|
# File 'lib/plos/article.rb', line 115
def sections
@sections ||= []
end
|
Class Method Details
.base_url ⇒ Object
57
58
59
|
# File 'lib/plos/article.rb', line 57
def self.base_url
"http://www.plosone.org"
end
|
.bib_tex_citation_url(id) ⇒ Object
82
83
84
|
# File 'lib/plos/article.rb', line 82
def self.bib_tex_citation_url(id)
"#{base_url}/article/getBibTexCitation.action?articleURI=info:doi/#{id}"
end
|
.citation(id, format = "RIS") ⇒ Object
.content(id) ⇒ Object
69
70
71
|
# File 'lib/plos/article.rb', line 69
def self.content(id)
RestClient.get(self.url(id))
end
|
.get(id) ⇒ Object
61
62
63
|
# File 'lib/plos/article.rb', line 61
def self.get(id)
PLOS::Article.new(id, self.xml(id))
end
|
.ris_citation_url(id) ⇒ Object
78
79
80
|
# File 'lib/plos/article.rb', line 78
def self.ris_citation_url(id)
"#{base_url}/article/getRisCitation.action?articleURI=info:doi/#{id}"
end
|
.url(id, format = "XML") ⇒ Object
73
74
75
76
|
# File 'lib/plos/article.rb', line 73
def self.url(id, format="XML")
"#{base_url}/article/fetchObjectAttachment.action?uri=info:doi/#{id}&representation=#{format}"
end
|
.xml(id) ⇒ Object
65
66
67
|
# File 'lib/plos/article.rb', line 65
def self.xml(id)
Nokogiri::XML(self.content(id))
end
|
Instance Method Details
#authors ⇒ Object
91
92
93
|
# File 'lib/plos/article.rb', line 91
def authors
contributors.collect { |contrib| contrib.name if contrib.type == "author" }.compact
end
|
#citation(format = "RIS") ⇒ Object
123
124
125
|
# File 'lib/plos/article.rb', line 123
def citation(format="RIS")
PLOS::Article.citation(id, format)
end
|
#editors ⇒ Object
95
96
97
|
# File 'lib/plos/article.rb', line 95
def editors
contributors.collect { |contrib| contrib.name if contrib.type == "editor" }.compact
end
|