Class: StructuredData::BreadcrumbList

Inherits:
Object
  • Object
show all
Defined in:
lib/structured_data.rb

Instance Method Summary collapse

Constructor Details

#initializeBreadcrumbList

Returns a new instance of BreadcrumbList.



68
69
70
# File 'lib/structured_data.rb', line 68

def initialize
  @items = []
end

Instance Method Details

#<<(item) ⇒ Object



72
73
74
# File 'lib/structured_data.rb', line 72

def <<(item)
  @items << item
end

#dumpObject



80
81
82
83
84
85
86
87
88
# File 'lib/structured_data.rb', line 80

def dump
  hash = {
    "@context": "http://schema.org",
    "@type": "BreadcrumbList",
  }

  hash['itemListElement'] = items_to_hash
  JSON.pretty_generate(hash)
end

#empty?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/structured_data.rb', line 76

def empty?
  @items.empty?
end