Class: Gretel::JSONLD::Breadcrumb::ListItem

Inherits:
Object
  • Object
show all
Defined in:
lib/gretel/jsonld/breadcrumb/list_item.rb

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, position:) ⇒ ListItem

Returns a new instance of ListItem.



11
12
13
14
15
# File 'lib/gretel/jsonld/breadcrumb/list_item.rb', line 11

def initialize(id:, name:, position:)
  @id = id
  @name = name
  @position = position
end

Instance Method Details

#as_json(options = nil) ⇒ Object

NOTE: Override #as_json to cope with Rails 4.0 or former



18
19
20
21
22
23
24
25
26
27
# File 'lib/gretel/jsonld/breadcrumb/list_item.rb', line 18

def as_json(options = nil)
  {
    "@type": "ListItem",
    position: @position,
    item: {
      "@id": @id,
      name: @name,
    }
  }.as_json(options)
end

#to_json(*args) ⇒ Object



29
30
31
# File 'lib/gretel/jsonld/breadcrumb/list_item.rb', line 29

def to_json(*args)
  as_json.to_json(*args)
end