Class: SerpCheap::RankResponse
- Inherits:
-
Object
- Object
- SerpCheap::RankResponse
- Defined in:
- lib/serpcheap/models.rb
Instance Attribute Summary collapse
-
#found ⇒ Object
readonly
Returns the value of attribute found.
-
#gl ⇒ Object
readonly
Returns the value of attribute gl.
-
#match_type ⇒ Object
readonly
Returns the value of attribute match_type.
-
#matches ⇒ Object
readonly
Returns the value of attribute matches.
-
#organic ⇒ Object
readonly
Returns the value of attribute organic.
-
#pages_failed ⇒ Object
readonly
Returns the value of attribute pages_failed.
-
#pages_scanned ⇒ Object
readonly
Returns the value of attribute pages_scanned.
-
#partial ⇒ Object
readonly
Returns the value of attribute partial.
-
#rank ⇒ Object
readonly
Returns the value of attribute rank.
-
#search ⇒ Object
readonly
Returns the value of attribute search.
-
#stats ⇒ Object
readonly
Returns the value of attribute stats.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(url:, search:, gl:, match_type:, pages_scanned:, found:, rank:, matches:, organic:, partial:, pages_failed:, stats: nil) ⇒ RankResponse
constructor
A new instance of RankResponse.
Constructor Details
#initialize(url:, search:, gl:, match_type:, pages_scanned:, found:, rank:, matches:, organic:, partial:, pages_failed:, stats: nil) ⇒ RankResponse
Returns a new instance of RankResponse.
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/serpcheap/models.rb', line 244 def initialize(url:, search:, gl:, match_type:, pages_scanned:, found:, rank:, matches:, organic:, partial:, pages_failed:, stats: nil) @url = url @search = search @gl = gl @match_type = match_type @pages_scanned = pages_scanned @found = found @rank = rank @matches = matches @organic = organic @partial = partial @pages_failed = pages_failed @stats = stats end |
Instance Attribute Details
#found ⇒ Object (readonly)
Returns the value of attribute found.
241 242 243 |
# File 'lib/serpcheap/models.rb', line 241 def found @found end |
#gl ⇒ Object (readonly)
Returns the value of attribute gl.
241 242 243 |
# File 'lib/serpcheap/models.rb', line 241 def gl @gl end |
#match_type ⇒ Object (readonly)
Returns the value of attribute match_type.
241 242 243 |
# File 'lib/serpcheap/models.rb', line 241 def match_type @match_type end |
#matches ⇒ Object (readonly)
Returns the value of attribute matches.
241 242 243 |
# File 'lib/serpcheap/models.rb', line 241 def matches @matches end |
#organic ⇒ Object (readonly)
Returns the value of attribute organic.
241 242 243 |
# File 'lib/serpcheap/models.rb', line 241 def organic @organic end |
#pages_failed ⇒ Object (readonly)
Returns the value of attribute pages_failed.
241 242 243 |
# File 'lib/serpcheap/models.rb', line 241 def pages_failed @pages_failed end |
#pages_scanned ⇒ Object (readonly)
Returns the value of attribute pages_scanned.
241 242 243 |
# File 'lib/serpcheap/models.rb', line 241 def pages_scanned @pages_scanned end |
#partial ⇒ Object (readonly)
Returns the value of attribute partial.
241 242 243 |
# File 'lib/serpcheap/models.rb', line 241 def partial @partial end |
#rank ⇒ Object (readonly)
Returns the value of attribute rank.
241 242 243 |
# File 'lib/serpcheap/models.rb', line 241 def rank @rank end |
#search ⇒ Object (readonly)
Returns the value of attribute search.
241 242 243 |
# File 'lib/serpcheap/models.rb', line 241 def search @search end |
#stats ⇒ Object (readonly)
Returns the value of attribute stats.
241 242 243 |
# File 'lib/serpcheap/models.rb', line 241 def stats @stats end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
241 242 243 |
# File 'lib/serpcheap/models.rb', line 241 def url @url end |
Class Method Details
.from_hash(d) ⇒ Object
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/serpcheap/models.rb', line 260 def self.from_hash(d) new( url: d["url"].to_s, search: d["search"].to_s, gl: d["gl"].to_s, match_type: (d["match_type"] || "domain").to_s, pages_scanned: d["pages_scanned"].to_i, found: d["found"] == true, rank: d["rank"].nil? ? nil : d["rank"].to_i, matches: Array(d["matches"]).map { |m| RankMatch.from_hash(m) }, organic: Array(d["organic"]).map { |o| OrganicResult.from_hash(o) }, partial: d["partial"] == true, pages_failed: Array(d["pages_failed"]).map(&:to_i), stats: d["stats"].is_a?(Hash) ? RankStats.from_hash(d["stats"]) : nil ) end |