Class: StructuredData::SiteNavigationElement

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

Instance Method Summary collapse

Constructor Details

#initializeSiteNavigationElement

Returns a new instance of SiteNavigationElement.



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

def initialize
  @urls  = []
  @names = []
end

Instance Method Details

#<<(item) ⇒ Object



77
78
79
80
81
82
# File 'lib/structured_data.rb', line 77

def <<(item)
  @urls  << item[:url]
  @names << item[:name]

  item
end

#dumpObject



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/structured_data.rb', line 88

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

  hash[:url] = @urls
  hash[:name] = @names

  JSON.pretty_generate(hash)
end

#empty?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/structured_data.rb', line 84

def empty?
  @urls.empty? && @names.empty?
end