Class: PageStructuredData::PageTypes::Organization

Inherits:
Object
  • Object
show all
Includes:
SchemaNode
Defined in:
app/src/page_structured_data/page_types/organization.rb

Overview

Organization structured data for a page

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, url:, description: nil, logo: nil, same_as: [], parent_organization: nil, founder: nil) ⇒ Organization

Returns a new instance of Organization.



11
12
13
14
15
16
17
18
19
# File 'app/src/page_structured_data/page_types/organization.rb', line 11

def initialize(name:, url:, description: nil, logo: nil, same_as: [], parent_organization: nil, founder: nil)
  @name = name
  @url = url
  @description = description
  @logo = 
  @same_as = Array(same_as)
  @parent_organization = parent_organization
  @founder = founder
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



9
10
11
# File 'app/src/page_structured_data/page_types/organization.rb', line 9

def description
  @description
end

#founderObject (readonly)

Returns the value of attribute founder.



9
10
11
# File 'app/src/page_structured_data/page_types/organization.rb', line 9

def founder
  @founder
end

#logoObject (readonly)

Returns the value of attribute logo.



9
10
11
# File 'app/src/page_structured_data/page_types/organization.rb', line 9

def 
  @logo
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'app/src/page_structured_data/page_types/organization.rb', line 9

def name
  @name
end

#parent_organizationObject (readonly)

Returns the value of attribute parent_organization.



9
10
11
# File 'app/src/page_structured_data/page_types/organization.rb', line 9

def parent_organization
  @parent_organization
end

#same_asObject (readonly)

Returns the value of attribute same_as.



9
10
11
# File 'app/src/page_structured_data/page_types/organization.rb', line 9

def same_as
  @same_as
end

#urlObject (readonly)

Returns the value of attribute url.



9
10
11
# File 'app/src/page_structured_data/page_types/organization.rb', line 9

def url
  @url
end

Instance Method Details

#json_ldObject



35
36
37
38
39
40
41
# File 'app/src/page_structured_data/page_types/organization.rb', line 35

def json_ld
  %(
  <script type="application/ld+json">
    #{to_h.to_json}
    </script>
  )
end

#to_hObject

rubocop:disable Metrics/MethodLength



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/src/page_structured_data/page_types/organization.rb', line 21

def to_h # rubocop:disable Metrics/MethodLength
  compact_node(
    '@context': 'https://schema.org',
    '@type': 'Organization',
    name: name,
    url: url,
    description: description,
    logo: ,
    sameAs: same_as,
    founder: object_to_h(founder),
    parentOrganization: parent_organization_to_h
  )
end