Class: RichSnippet::PostalAddress

Inherits:
Thing
  • Object
show all
Defined in:
app/models/rich_snippet/postal_address.rb

Instance Method Summary collapse

Methods inherited from Thing

#array_json, #module, #name, #type, #warnings

Instance Method Details

#to_json(render_childs = false) ⇒ Object


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/models/rich_snippet/postal_address.rb', line 13

def to_json(render_childs = false)
  {
    "@context": "http://schema.org",
    "@type": "PostalAddress",
    name: name,
    description: description,
    image: image ? image.binary_url : '',
    url: url,
    addressCountry: address_country,
    addressLocality: address_locality,
    addressRegion: address_region,
    postOfficeBoxNumber: post_office_box_number,
    postalCode: postal_code,
    streetAddress: street_address,
    email: email,
    telephone: telephone,
    faxNumber: fax_number
  }.delete_if { |k, v| !v.present? }
end