class Gretel::JSONLD::Breadcrumb::List
Public Class Methods
new(link_collection)
click to toggle source
# File lib/gretel/jsonld/breadcrumb/list.rb, line 12 def initialize(link_collection) @link_collection = link_collection end
Public Instance Methods
as_json(options = nil)
click to toggle source
NOTE: Override as_json
to cope with Rails 4.0 or former
# File lib/gretel/jsonld/breadcrumb/list.rb, line 17 def as_json(options = nil) { "@context": "http://schema.org", "@type": "BreadcrumbList", itemListElement: item_list_element, }.as_json(options) end
to_json(*args)
click to toggle source
# File lib/gretel/jsonld/breadcrumb/list.rb, line 25 def to_json(*args) as_json.to_json(*args) end
Private Instance Methods
item_list_element()
click to toggle source
# File lib/gretel/jsonld/breadcrumb/list.rb, line 31 def item_list_element @link_collection.map.with_index(1) do |link, index| ::Gretel::JSONLD::Breadcrumb::ListItem.new( id: link.url, name: link.text, position: index, ) end end