class Nucleo::Models::Page
Public Class Methods
Return an instance of the Page
domain model
@param attributes [Hash]
@return [Nucleo::Models::Page]
# File lib/nucleo/models/page.rb, line 9 def initialize(attributes={}) @attributes = attributes end
Public Instance Methods
Returns a Feeds
collection of alerts for this page
@return [Nucleo::Models::Feeds]
# File lib/nucleo/models/page.rb, line 90 def alerts Nucleo::Models::Feeds.new(@attributes.fetch('alerts', [])) end
Returns true if there are any alerts
@return [Boolean]
# File lib/nucleo/models/page.rb, line 97 def alerts? self.alerts.any? end
Returns a collection of Analytics
@return [Array]
# File lib/nucleo/models/page.rb, line 104 def analytics Nucleo::Models::Feeds.new(@attributes.fetch('analytics', [])) end
Returns true if there are any analytics
@return [Boolean]
# File lib/nucleo/models/page.rb, line 111 def analytics? self.analytics.any? end
Returns the date the page was crawled
@return [DateTime,nil]
# File lib/nucleo/models/page.rb, line 58 def crawled_at begin DateTime.parse(@attributes['crawled_at']) rescue nil end end
Returns the hostname of the page
@return [String]
# File lib/nucleo/models/page.rb, line 37 def hostname @attributes['hostname'] end
Returns the ID of the page
@return [String]
# File lib/nucleo/models/page.rb, line 16 def id @attributes['id'] end
Returns metrics for this page
@return [Nucleo::Models::PageMetric]
# File lib/nucleo/models/page.rb, line 118 def metrics Nucleo::Models::PageMetric.new(@attributes.fetch('metrics', [])) end
Returns true if there are any metrics
@return [Boolean]
# File lib/nucleo/models/page.rb, line 125 def metrics? self.metrics.any? end
Returns the path of the page
@return [String]
# File lib/nucleo/models/page.rb, line 30 def path @attributes['path'] end
Returns a Feeds
collection of recommendations for this page
@return [Nucleo::Models::Feeds]
# File lib/nucleo/models/page.rb, line 76 def recommendations Nucleo::Models::Feeds.new(@attributes.fetch('recommendations', [])) end
Returns true if there are any recommendations
@return [Boolean]
# File lib/nucleo/models/page.rb, line 83 def recommendations? self.recommendations.any? end
Returns the resolved URL of the page
@return [String]
# File lib/nucleo/models/page.rb, line 51 def resolved_url @attributes['resolved_url'].to_s end
Returns a set of rules
@return [Nucleo::Models::Rules]
# File lib/nucleo/models/page.rb, line 69 def rules Nucleo::Models::Rules.new(@attributes.fetch('rules', [])) end
Returns the SeoScore
domain model for this page
@return [Nucleo::Models::SeoScore]
# File lib/nucleo/models/page.rb, line 132 def seo_score Nucleo::Models::SeoScore.new(seo_score_params) end
Returns the title of the page
@return [String]
# File lib/nucleo/models/page.rb, line 23 def title @attributes['title'] end
Returns the URI of the resolved URL
@return [URI]
# File lib/nucleo/models/page.rb, line 44 def url URI(self.resolved_url) end
Private Instance Methods
# File lib/nucleo/models/page.rb, line 137 def seo_score_params reference = @attributes.fetch('seo_score', {}) { 'score' => reference['seo_score'], 'grade' => reference['seo_grade'] } end