Class: SerpCheap::ScrapeResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/serpcheap/models.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:, status: nil, title: nil, content: nil, content_text: nil, screenshot_url: nil, stats: nil) ⇒ ScrapeResponse

Returns a new instance of ScrapeResponse.



175
176
177
178
179
180
181
182
183
# File 'lib/serpcheap/models.rb', line 175

def initialize(url:, status: nil, title: nil, content: nil, content_text: nil, screenshot_url: nil, stats: nil)
  @url = url
  @status = status
  @title = title
  @content = content
  @content_text = content_text
  @screenshot_url = screenshot_url
  @stats = stats
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



173
174
175
# File 'lib/serpcheap/models.rb', line 173

def content
  @content
end

#content_textObject (readonly)

Returns the value of attribute content_text.



173
174
175
# File 'lib/serpcheap/models.rb', line 173

def content_text
  @content_text
end

#screenshot_urlObject (readonly)

Returns the value of attribute screenshot_url.



173
174
175
# File 'lib/serpcheap/models.rb', line 173

def screenshot_url
  @screenshot_url
end

#statsObject (readonly)

Returns the value of attribute stats.



173
174
175
# File 'lib/serpcheap/models.rb', line 173

def stats
  @stats
end

#statusObject (readonly)

Returns the value of attribute status.



173
174
175
# File 'lib/serpcheap/models.rb', line 173

def status
  @status
end

#titleObject (readonly)

Returns the value of attribute title.



173
174
175
# File 'lib/serpcheap/models.rb', line 173

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



173
174
175
# File 'lib/serpcheap/models.rb', line 173

def url
  @url
end

Class Method Details

.from_hash(d) ⇒ Object



185
186
187
188
189
190
191
192
193
194
195
# File 'lib/serpcheap/models.rb', line 185

def self.from_hash(d)
  new(
    url: d["url"].to_s,
    status: d["status"]&.to_i,
    title: d["title"],
    content: d["content"],
    content_text: d["content_text"],
    screenshot_url: d["screenshot_url"],
    stats: d["stats"].is_a?(Hash) ? ScrapeStats.from_hash(d["stats"]) : nil
  )
end