Class: SerpCheap::OrganicResult
- Inherits:
-
Object
- Object
- SerpCheap::OrganicResult
- Defined in:
- lib/serpcheap/models.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#scrape_error ⇒ Object
readonly
Returns the value of attribute scrape_error.
-
#screenshot_url ⇒ Object
readonly
Returns the value of attribute screenshot_url.
-
#sitelinks ⇒ Object
readonly
Returns the value of attribute sitelinks.
-
#snippet ⇒ Object
readonly
Returns the value of attribute snippet.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(position:, title:, link:, snippet:, date: nil, sitelinks: nil, content: nil, screenshot_url: nil, scrape_error: nil) ⇒ OrganicResult
constructor
A new instance of OrganicResult.
Constructor Details
#initialize(position:, title:, link:, snippet:, date: nil, sitelinks: nil, content: nil, screenshot_url: nil, scrape_error: nil) ⇒ OrganicResult
Returns a new instance of OrganicResult.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/serpcheap/models.rb', line 21 def initialize(position:, title:, link:, snippet:, date: nil, sitelinks: nil, content: nil, screenshot_url: nil, scrape_error: nil) @position = position @title = title @link = link @snippet = snippet @date = date @sitelinks = sitelinks @content = content @screenshot_url = screenshot_url @scrape_error = scrape_error end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
18 19 20 |
# File 'lib/serpcheap/models.rb', line 18 def content @content end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
18 19 20 |
# File 'lib/serpcheap/models.rb', line 18 def date @date end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
18 19 20 |
# File 'lib/serpcheap/models.rb', line 18 def link @link end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
18 19 20 |
# File 'lib/serpcheap/models.rb', line 18 def position @position end |
#scrape_error ⇒ Object (readonly)
Returns the value of attribute scrape_error.
18 19 20 |
# File 'lib/serpcheap/models.rb', line 18 def scrape_error @scrape_error end |
#screenshot_url ⇒ Object (readonly)
Returns the value of attribute screenshot_url.
18 19 20 |
# File 'lib/serpcheap/models.rb', line 18 def screenshot_url @screenshot_url end |
#sitelinks ⇒ Object (readonly)
Returns the value of attribute sitelinks.
18 19 20 |
# File 'lib/serpcheap/models.rb', line 18 def sitelinks @sitelinks end |
#snippet ⇒ Object (readonly)
Returns the value of attribute snippet.
18 19 20 |
# File 'lib/serpcheap/models.rb', line 18 def snippet @snippet end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
18 19 20 |
# File 'lib/serpcheap/models.rb', line 18 def title @title end |
Class Method Details
.from_hash(d) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/serpcheap/models.rb', line 34 def self.from_hash(d) sl = d["sitelinks"] new( position: d["position"].to_i, title: d["title"].to_s, link: d["link"].to_s, snippet: d["snippet"].to_s, date: d["date"], sitelinks: sl.is_a?(Array) ? sl.map { |s| Sitelink.from_hash(s) } : nil, content: d["content"], screenshot_url: d["screenshot_url"], scrape_error: d["scrape_error"] ) end |