Class: StructuredData::SiteNavigationElement
- Inherits:
-
Object
- Object
- StructuredData::SiteNavigationElement
- Defined in:
- lib/structured_data.rb
Instance Method Summary collapse
- #<<(item) ⇒ Object
- #dump ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ SiteNavigationElement
constructor
A new instance of SiteNavigationElement.
Constructor Details
#initialize ⇒ SiteNavigationElement
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 |
#dump ⇒ Object
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
84 85 86 |
# File 'lib/structured_data.rb', line 84 def empty? @urls.empty? && @names.empty? end |