Class: Nucleo::Models::Page
- Inherits:
-
Object
- Object
- Nucleo::Models::Page
- Defined in:
- lib/nucleo/models/page.rb
Instance Method Summary collapse
-
#alerts ⇒ Nucleo::Models::Feeds
Returns a Feeds collection of alerts for this page.
-
#alerts? ⇒ Boolean
Returns true if there are any alerts.
-
#analytics ⇒ Array
Returns a collection of Analytics.
-
#analytics? ⇒ Boolean
Returns true if there are any analytics.
-
#crawled_at ⇒ DateTime?
Returns the date the page was crawled.
-
#hostname ⇒ String
Returns the hostname of the page.
-
#id ⇒ String
Returns the ID of the page.
-
#initialize(attributes = {}) ⇒ Nucleo::Models::Page
constructor
Return an instance of the Page domain model.
-
#metrics ⇒ Nucleo::Models::PageMetric
Returns metrics for this page.
-
#metrics? ⇒ Boolean
Returns true if there are any metrics.
-
#path ⇒ String
Returns the path of the page.
-
#recommendations ⇒ Nucleo::Models::Feeds
Returns a Feeds collection of recommendations for this page.
-
#recommendations? ⇒ Boolean
Returns true if there are any recommendations.
-
#resolved_url ⇒ String
Returns the resolved URL of the page.
-
#rules ⇒ Nucleo::Models::Rules
Returns a set of rules.
-
#seo_score ⇒ Nucleo::Models::SeoScore
Returns the SeoScore domain model for this page.
-
#title ⇒ String
Returns the title of the page.
-
#url ⇒ URI
Returns the URI of the resolved URL.
Constructor Details
#initialize(attributes = {}) ⇒ Nucleo::Models::Page
Return an instance of the Page domain model
9 10 11 |
# File 'lib/nucleo/models/page.rb', line 9 def initialize(attributes={}) @attributes = attributes end |
Instance Method Details
#alerts ⇒ Nucleo::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
97 98 99 |
# File 'lib/nucleo/models/page.rb', line 97 def alerts? self.alerts.any? end |
#analytics ⇒ Array
Returns a collection of Analytics
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
111 112 113 |
# File 'lib/nucleo/models/page.rb', line 111 def analytics? self.analytics.any? end |
#crawled_at ⇒ DateTime?
Returns the date the page was crawled
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 |
#hostname ⇒ String
Returns the hostname of the page
37 38 39 |
# File 'lib/nucleo/models/page.rb', line 37 def hostname @attributes['hostname'] end |
#id ⇒ String
Returns the ID of the page
16 17 18 |
# File 'lib/nucleo/models/page.rb', line 16 def id @attributes['id'] end |
#metrics ⇒ Nucleo::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
125 126 127 |
# File 'lib/nucleo/models/page.rb', line 125 def metrics? self.metrics.any? end |
#path ⇒ String
Returns the path of the page
30 31 32 |
# File 'lib/nucleo/models/page.rb', line 30 def path @attributes['path'] end |
#recommendations ⇒ Nucleo::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
83 84 85 |
# File 'lib/nucleo/models/page.rb', line 83 def recommendations? self.recommendations.any? end |
#resolved_url ⇒ String
Returns the resolved URL of the page
51 52 53 |
# File 'lib/nucleo/models/page.rb', line 51 def resolved_url @attributes['resolved_url'].to_s end |
#rules ⇒ Nucleo::Models::Rules
Returns a set of rules
69 70 71 |
# File 'lib/nucleo/models/page.rb', line 69 def rules Nucleo::Models::Rules.new(@attributes.fetch('rules', [])) end |
#seo_score ⇒ Nucleo::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 |
#title ⇒ String
Returns the title of the page
23 24 25 |
# File 'lib/nucleo/models/page.rb', line 23 def title @attributes['title'] end |
#url ⇒ URI
Returns the URI of the resolved URL
44 45 46 |
# File 'lib/nucleo/models/page.rb', line 44 def url URI(self.resolved_url) end |