Class: Google::Scholar::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/google/scholar/document.rb

Direct Known Subclasses

AuthorsDocument, AuthorsProfileDocument

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nokogiri_document) ⇒ Document

Returns a new instance of Document.



5
6
7
# File 'lib/google/scholar/document.rb', line 5

def initialize(nokogiri_document)
  @document = nokogiri_document
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/google/scholar/document.rb', line 8

def method_missing(meth, *args, &block)
  if(@document.respond_to?(meth))
    return @document.send(meth,*args,&block)
  else
    super
  end
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



4
5
6
# File 'lib/google/scholar/document.rb', line 4

def document
  @document
end

Instance Method Details

#has_next_page?Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
# File 'lib/google/scholar/document.rb', line 15

def has_next_page?
  @document.css('.cit-dgb .cit-dark-link').each do |link|
    return true if link.content.include?("Next")
  end
  return false
end

#next_page_urlObject



21
22
23
24
25
26
27
28
# File 'lib/google/scholar/document.rb', line 21

def next_page_url
  return nil unless self.has_next_page?
  @document.css('.cit-dgb .cit-dark-link').each do |link|
    if(link.content.include?("Next"))
      return "#{Google::Scholar.google_url}#{link.attr("href")}"
    end
  end
end