class Nucleo::Models::Page

Public Class Methods

new(attributes={}) click to toggle source

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

alerts() click to toggle source

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
alerts?() click to toggle source

Returns true if there are any alerts

@return [Boolean]

# File lib/nucleo/models/page.rb, line 97
def alerts?
  self.alerts.any?
end
analytics() click to toggle source

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
analytics?() click to toggle source

Returns true if there are any analytics

@return [Boolean]

# File lib/nucleo/models/page.rb, line 111
def analytics?
  self.analytics.any?
end
crawled_at() click to toggle source

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
hostname() click to toggle source

Returns the hostname of the page

@return [String]

# File lib/nucleo/models/page.rb, line 37
def hostname
  @attributes['hostname']
end
id() click to toggle source

Returns the ID of the page

@return [String]

# File lib/nucleo/models/page.rb, line 16
def id
  @attributes['id']
end
metrics() click to toggle source

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
metrics?() click to toggle source

Returns true if there are any metrics

@return [Boolean]

# File lib/nucleo/models/page.rb, line 125
def metrics?
  self.metrics.any?
end
path() click to toggle source

Returns the path of the page

@return [String]

# File lib/nucleo/models/page.rb, line 30
def path
  @attributes['path']
end
recommendations() click to toggle source

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
recommendations?() click to toggle source

Returns true if there are any recommendations

@return [Boolean]

# File lib/nucleo/models/page.rb, line 83
def recommendations?
  self.recommendations.any?
end
resolved_url() click to toggle source

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
rules() click to toggle source

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
seo_score() click to toggle source

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
title() click to toggle source

Returns the title of the page

@return [String]

# File lib/nucleo/models/page.rb, line 23
def title
  @attributes['title']
end
url() click to toggle source

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

seo_score_params() click to toggle source
# 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