Class: Www::CollectionPagePresenter

Inherits:
BasePresenter show all
Defined in:
app/presenters/www/collection_page_presenter.rb

Instance Attribute Summary collapse

Attributes inherited from BasePresenter

#current_account, #options, #url_helper

Instance Method Summary collapse

Methods inherited from BasePresenter

#can?, #capture, #concat, #content_tag, #fa_icon, #h, #link_to, #number_to_currency, #present, presents, #r, #safe_present, #simple_format, #u

Constructor Details

#initialize(page_title, page_description, page_url, items = [], request = nil) ⇒ CollectionPagePresenter

Returns a new instance of CollectionPagePresenter.



7
8
9
10
11
12
13
14
# File 'app/presenters/www/collection_page_presenter.rb', line 7

def initialize(page_title, page_description, page_url, items = [], request = nil)
  @page_title = page_title
  @page_description = page_description
  @page_url = page_url
  @items = items
  @request = request
  super(nil) # Pass nil since we don't need a model
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



5
6
7
# File 'app/presenters/www/collection_page_presenter.rb', line 5

def items
  @items
end

#page_descriptionObject (readonly)

Returns the value of attribute page_description.



5
6
7
# File 'app/presenters/www/collection_page_presenter.rb', line 5

def page_description
  @page_description
end

#page_titleObject (readonly)

Returns the value of attribute page_title.



5
6
7
# File 'app/presenters/www/collection_page_presenter.rb', line 5

def page_title
  @page_title
end

#page_urlObject (readonly)

Returns the value of attribute page_url.



5
6
7
# File 'app/presenters/www/collection_page_presenter.rb', line 5

def page_url
  @page_url
end

#requestObject (readonly)

Returns the value of attribute request.



5
6
7
# File 'app/presenters/www/collection_page_presenter.rb', line 5

def request
  @request
end

Instance Method Details

#schema_dot_org_structureObject



16
17
18
19
20
21
22
23
# File 'app/presenters/www/collection_page_presenter.rb', line 16

def schema_dot_org_structure
  SchemaDotOrg::CollectionPage.new(
    name: page_title,
    description: page_description,
    url: page_url,
    mainEntity: build_item_list
  )
end

#to_json_ldObject



25
26
27
# File 'app/presenters/www/collection_page_presenter.rb', line 25

def to_json_ld
  schema_dot_org_structure.to_s
end