Class: Google::Scholar::Document
- Inherits:
-
Object
- Object
- Google::Scholar::Document
- Defined in:
- lib/google/scholar/document.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
Instance Method Summary collapse
- #has_next_page? ⇒ Boolean
-
#initialize(nokogiri_document) ⇒ Document
constructor
A new instance of Document.
- #method_missing(meth, *args, &block) ⇒ Object
- #next_page_url ⇒ Object
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
#document ⇒ Object (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
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_url ⇒ Object
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 |