Class: Nucleo::Models::Page

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

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Nucleo::Models::Page

Return an instance of the Page domain model

Parameters:

  • attributes (Hash) (defaults to: {})


9
10
11
# File 'lib/nucleo/models/page.rb', line 9

def initialize(attributes={})
  @attributes = attributes
end

Instance Method Details

#alertsNucleo::Models::Feeds

Returns a Feeds collection of alerts for this page



90
91
92
# File 'lib/nucleo/models/page.rb', line 90

def alerts
  Nucleo::Models::Feeds.new(@attributes.fetch('alerts', []))
end

#alerts?Boolean

Returns true if there are any alerts

Returns:

  • (Boolean)


97
98
99
# File 'lib/nucleo/models/page.rb', line 97

def alerts?
  self.alerts.any?
end

#analyticsArray

Returns a collection of Analytics

Returns:

  • (Array)


104
105
106
# File 'lib/nucleo/models/page.rb', line 104

def analytics
  Nucleo::Models::Feeds.new(@attributes.fetch('analytics', []))
end

#analytics?Boolean

Returns true if there are any analytics

Returns:

  • (Boolean)


111
112
113
# File 'lib/nucleo/models/page.rb', line 111

def analytics?
  self.analytics.any?
end

#crawled_atDateTime?

Returns the date the page was crawled

Returns:

  • (DateTime, nil)


58
59
60
61
62
63
64
# File 'lib/nucleo/models/page.rb', line 58

def crawled_at
  begin
    DateTime.parse(@attributes['crawled_at'])
  rescue
    nil
  end
end

#hostnameString

Returns the hostname of the page

Returns:

  • (String)


37
38
39
# File 'lib/nucleo/models/page.rb', line 37

def hostname
  @attributes['hostname']
end

#idString

Returns the ID of the page

Returns:

  • (String)


16
17
18
# File 'lib/nucleo/models/page.rb', line 16

def id
  @attributes['id']
end

#metricsNucleo::Models::PageMetric

Returns metrics for this page



118
119
120
# File 'lib/nucleo/models/page.rb', line 118

def metrics
  Nucleo::Models::PageMetric.new(@attributes.fetch('metrics', []))
end

#metrics?Boolean

Returns true if there are any metrics

Returns:

  • (Boolean)


125
126
127
# File 'lib/nucleo/models/page.rb', line 125

def metrics?
  self.metrics.any?
end

#pathString

Returns the path of the page

Returns:

  • (String)


30
31
32
# File 'lib/nucleo/models/page.rb', line 30

def path
  @attributes['path']
end

#recommendationsNucleo::Models::Feeds

Returns a Feeds collection of recommendations for this page



76
77
78
# File 'lib/nucleo/models/page.rb', line 76

def recommendations
  Nucleo::Models::Feeds.new(@attributes.fetch('recommendations', []))
end

#recommendations?Boolean

Returns true if there are any recommendations

Returns:

  • (Boolean)


83
84
85
# File 'lib/nucleo/models/page.rb', line 83

def recommendations?
  self.recommendations.any?
end

#resolved_urlString

Returns the resolved URL of the page

Returns:

  • (String)


51
52
53
# File 'lib/nucleo/models/page.rb', line 51

def resolved_url
  @attributes['resolved_url'].to_s
end

#rulesNucleo::Models::Rules

Returns a set of rules

Returns:

  • (Nucleo::Models::Rules)


69
70
71
# File 'lib/nucleo/models/page.rb', line 69

def rules
  Nucleo::Models::Rules.new(@attributes.fetch('rules', []))
end

#seo_scoreNucleo::Models::SeoScore

Returns the SeoScore domain model for this page



132
133
134
# File 'lib/nucleo/models/page.rb', line 132

def seo_score
  Nucleo::Models::SeoScore.new(seo_score_params)
end

#titleString

Returns the title of the page

Returns:

  • (String)


23
24
25
# File 'lib/nucleo/models/page.rb', line 23

def title
  @attributes['title']
end

#urlURI

Returns the URI of the resolved URL

Returns:

  • (URI)


44
45
46
# File 'lib/nucleo/models/page.rb', line 44

def url
  URI(self.resolved_url)
end