Class: GoogleScholar::Article
- Inherits:
-
Object
- Object
- GoogleScholar::Article
- Extended by:
- ActiveSupport::Memoizable
- Defined in:
- lib/google_scholar/article.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
Instance Method Summary collapse
- #cites_count ⇒ Object
- #cites_element ⇒ Object
- #cites_link ⇒ Object
- #details ⇒ Object
-
#initialize(doc) ⇒ Article
constructor
A new instance of Article.
- #link ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(doc) ⇒ Article
Returns a new instance of Article.
9 10 11 |
# File 'lib/google_scholar/article.rb', line 9 def initialize(doc) @doc = doc end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
7 8 9 |
# File 'lib/google_scholar/article.rb', line 7 def doc @doc end |
Instance Method Details
#cites_count ⇒ Object
35 36 37 38 39 |
# File 'lib/google_scholar/article.rb', line 35 def cites_count cites_element ? cites_element.text.gsub("Cited by ", "").to_i : 0 end |
#cites_element ⇒ Object
25 26 27 |
# File 'lib/google_scholar/article.rb', line 25 def cites_element doc.css('.gs_fl a').select{ |l| l.text =~ /^Cited by/ }.first end |
#cites_link ⇒ Object
29 30 31 32 33 |
# File 'lib/google_scholar/article.rb', line 29 def cites_link cites_element ? GoogleScholar::ROOT_URL + cites_element['href'] : nil end |
#details ⇒ Object
21 22 23 |
# File 'lib/google_scholar/article.rb', line 21 def details doc.css('.gs_a').first.text end |
#link ⇒ Object
17 18 19 |
# File 'lib/google_scholar/article.rb', line 17 def link doc.css('h3 a').first['href'] end |
#title ⇒ Object
13 14 15 |
# File 'lib/google_scholar/article.rb', line 13 def title doc.css("h3").text end |