Class: SerpCheap::RankResponse

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:, 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

#foundObject (readonly)

Returns the value of attribute found.



241
242
243
# File 'lib/serpcheap/models.rb', line 241

def found
  @found
end

#glObject (readonly)

Returns the value of attribute gl.



241
242
243
# File 'lib/serpcheap/models.rb', line 241

def gl
  @gl
end

#match_typeObject (readonly)

Returns the value of attribute match_type.



241
242
243
# File 'lib/serpcheap/models.rb', line 241

def match_type
  @match_type
end

#matchesObject (readonly)

Returns the value of attribute matches.



241
242
243
# File 'lib/serpcheap/models.rb', line 241

def matches
  @matches
end

#organicObject (readonly)

Returns the value of attribute organic.



241
242
243
# File 'lib/serpcheap/models.rb', line 241

def organic
  @organic
end

#pages_failedObject (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_scannedObject (readonly)

Returns the value of attribute pages_scanned.



241
242
243
# File 'lib/serpcheap/models.rb', line 241

def pages_scanned
  @pages_scanned
end

#partialObject (readonly)

Returns the value of attribute partial.



241
242
243
# File 'lib/serpcheap/models.rb', line 241

def partial
  @partial
end

#rankObject (readonly)

Returns the value of attribute rank.



241
242
243
# File 'lib/serpcheap/models.rb', line 241

def rank
  @rank
end

#searchObject (readonly)

Returns the value of attribute search.



241
242
243
# File 'lib/serpcheap/models.rb', line 241

def search
  @search
end

#statsObject (readonly)

Returns the value of attribute stats.



241
242
243
# File 'lib/serpcheap/models.rb', line 241

def stats
  @stats
end

#urlObject (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