Class: GovukPublishingComponents::Presenters::Page
- Inherits:
-
Object
- Object
- GovukPublishingComponents::Presenters::Page
- Defined in:
- lib/govuk_publishing_components/presenters/machine_readable/page.rb
Instance Attribute Summary collapse
-
#local_assigns ⇒ Object
readonly
Returns the value of attribute local_assigns.
Instance Method Summary collapse
- #attachments ⇒ Object
- #base_path ⇒ Object
- #body ⇒ Object
- #canonical_url ⇒ Object
- #content_item ⇒ Object
- #description ⇒ Object
- #document_type ⇒ Object
- #has_image? ⇒ Boolean
- #image_alt_text ⇒ Object
- #image_placeholders ⇒ Object
- #image_url ⇒ Object
-
#initialize(local_assigns) ⇒ Page
constructor
A new instance of Page.
- #logo_url ⇒ Object
- #requested_path ⇒ Object
- #schema ⇒ Object
- #title ⇒ Object
- #withdrawn? ⇒ Boolean
Constructor Details
#initialize(local_assigns) ⇒ Page
Returns a new instance of Page.
6 7 8 |
# File 'lib/govuk_publishing_components/presenters/machine_readable/page.rb', line 6 def initialize(local_assigns) @local_assigns = local_assigns end |
Instance Attribute Details
#local_assigns ⇒ Object (readonly)
Returns the value of attribute local_assigns.
4 5 6 |
# File 'lib/govuk_publishing_components/presenters/machine_readable/page.rb', line 4 def local_assigns @local_assigns end |
Instance Method Details
#attachments ⇒ Object
54 55 56 |
# File 'lib/govuk_publishing_components/presenters/machine_readable/page.rb', line 54 def content_item.dig("details", "attachments") end |
#base_path ⇒ Object
50 51 52 |
# File 'lib/govuk_publishing_components/presenters/machine_readable/page.rb', line 50 def base_path content_item["base_path"] end |
#body ⇒ Object
18 19 20 |
# File 'lib/govuk_publishing_components/presenters/machine_readable/page.rb', line 18 def body local_assigns[:body] || content_item.dig("details", "body") end |
#canonical_url ⇒ Object
14 15 16 |
# File 'lib/govuk_publishing_components/presenters/machine_readable/page.rb', line 14 def canonical_url local_assigns[:canonical_url] || (Plek.new.website_root + content_item["base_path"]) end |
#content_item ⇒ Object
58 59 60 |
# File 'lib/govuk_publishing_components/presenters/machine_readable/page.rb', line 58 def content_item local_assigns[:content_item] end |
#description ⇒ Object
26 27 28 |
# File 'lib/govuk_publishing_components/presenters/machine_readable/page.rb', line 26 def description local_assigns[:description] || content_item["description"] end |
#document_type ⇒ Object
46 47 48 |
# File 'lib/govuk_publishing_components/presenters/machine_readable/page.rb', line 46 def document_type content_item["document_type"] end |
#has_image? ⇒ Boolean
30 31 32 |
# File 'lib/govuk_publishing_components/presenters/machine_readable/page.rb', line 30 def has_image? content_item.dig("details", "image").present? end |
#image_alt_text ⇒ Object
38 39 40 |
# File 'lib/govuk_publishing_components/presenters/machine_readable/page.rb', line 38 def image_alt_text content_item.dig("details", "image", "alt_text") end |
#image_placeholders ⇒ Object
42 43 44 |
# File 'lib/govuk_publishing_components/presenters/machine_readable/page.rb', line 42 def image_placeholders local_assigns[:image_placeholders] end |
#image_url ⇒ Object
34 35 36 |
# File 'lib/govuk_publishing_components/presenters/machine_readable/page.rb', line 34 def image_url content_item.dig("details", "image", "high_resolution_url") || content_item.dig("details", "image", "url") end |
#logo_url ⇒ Object
62 63 64 |
# File 'lib/govuk_publishing_components/presenters/machine_readable/page.rb', line 62 def logo_url local_assigns[:logo_url] end |
#requested_path ⇒ Object
66 67 68 |
# File 'lib/govuk_publishing_components/presenters/machine_readable/page.rb', line 66 def requested_path local_assigns[:request_path] end |
#schema ⇒ Object
10 11 12 |
# File 'lib/govuk_publishing_components/presenters/machine_readable/page.rb', line 10 def schema local_assigns.fetch(:schema) end |
#title ⇒ Object
22 23 24 |
# File 'lib/govuk_publishing_components/presenters/machine_readable/page.rb', line 22 def title local_assigns[:title] || content_item["title"] end |
#withdrawn? ⇒ Boolean
70 71 72 |
# File 'lib/govuk_publishing_components/presenters/machine_readable/page.rb', line 70 def withdrawn? content_item["withdrawn_notice"].present? end |