Class: PageStructuredData::PageTypes::WebSite
- Inherits:
-
Object
- Object
- PageStructuredData::PageTypes::WebSite
- Includes:
- SchemaNode
- Defined in:
- app/src/page_structured_data/page_types/web_site.rb
Overview
WebSite structured data for a page
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#potential_action ⇒ Object
readonly
Returns the value of attribute potential_action.
-
#publisher ⇒ Object
readonly
Returns the value of attribute publisher.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(name:, url:, description: nil, publisher: nil, potential_action: nil) ⇒ WebSite
constructor
A new instance of WebSite.
- #json_ld ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(name:, url:, description: nil, publisher: nil, potential_action: nil) ⇒ WebSite
Returns a new instance of WebSite.
11 12 13 14 15 16 17 |
# File 'app/src/page_structured_data/page_types/web_site.rb', line 11 def initialize(name:, url:, description: nil, publisher: nil, potential_action: nil) @name = name @url = url @description = description @publisher = publisher @potential_action = potential_action end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
9 10 11 |
# File 'app/src/page_structured_data/page_types/web_site.rb', line 9 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'app/src/page_structured_data/page_types/web_site.rb', line 9 def name @name end |
#potential_action ⇒ Object (readonly)
Returns the value of attribute potential_action.
9 10 11 |
# File 'app/src/page_structured_data/page_types/web_site.rb', line 9 def potential_action @potential_action end |
#publisher ⇒ Object (readonly)
Returns the value of attribute publisher.
9 10 11 |
# File 'app/src/page_structured_data/page_types/web_site.rb', line 9 def publisher @publisher end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
9 10 11 |
# File 'app/src/page_structured_data/page_types/web_site.rb', line 9 def url @url end |
Instance Method Details
#json_ld ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/src/page_structured_data/page_types/web_site.rb', line 31 def json_ld %( <script type="application/ld+json"> #{to_h.to_json} </script> ) end |
#to_h ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/src/page_structured_data/page_types/web_site.rb', line 19 def to_h compact_node( '@context': 'https://schema.org', '@type': 'WebSite', name: name, url: url, description: description, publisher: object_to_h(publisher), potentialAction: object_to_h(potential_action) ) end |