Class: PageStructuredData::PageTypes::WebSite
- Inherits:
-
Object
- Object
- PageStructuredData::PageTypes::WebSite
- 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.
9 10 11 12 13 14 15 |
# File 'app/src/page_structured_data/page_types/web_site.rb', line 9 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.
7 8 9 |
# File 'app/src/page_structured_data/page_types/web_site.rb', line 7 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'app/src/page_structured_data/page_types/web_site.rb', line 7 def name @name end |
#potential_action ⇒ Object (readonly)
Returns the value of attribute potential_action.
7 8 9 |
# File 'app/src/page_structured_data/page_types/web_site.rb', line 7 def potential_action @potential_action end |
#publisher ⇒ Object (readonly)
Returns the value of attribute publisher.
7 8 9 |
# File 'app/src/page_structured_data/page_types/web_site.rb', line 7 def publisher @publisher end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'app/src/page_structured_data/page_types/web_site.rb', line 7 def url @url end |
Instance Method Details
#json_ld ⇒ Object
32 33 34 35 36 37 38 |
# File 'app/src/page_structured_data/page_types/web_site.rb', line 32 def json_ld %( <script type="application/ld+json"> #{to_h.to_json} </script> ) end |
#to_h ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/src/page_structured_data/page_types/web_site.rb', line 17 def to_h node = { '@context': 'https://schema.org', '@type': 'WebSite', name: name, url: url, } node[:description] = description if description.present? node[:publisher] = publisher_to_h if publisher.present? node[:potentialAction] = potential_action if potential_action.present? node end |