Class: RichSnippet::Thing

Inherits:
Obj
  • Object
show all
Defined in:
app/models/rich_snippet/thing.rb

Instance Method Summary collapse

Instance Method Details

#array_json(attribute) ⇒ Object



20
21
22
23
24
25
26
# File 'app/models/rich_snippet/thing.rb', line 20

def array_json(attribute)
  o = []
  attribute.each do |elem|
    o << elem.to_json
  end
  return o
end

#moduleObject



12
13
14
# File 'app/models/rich_snippet/thing.rb', line 12

def module
  self.class.name.demodulize.downcase
end

#nameObject



8
9
10
# File 'app/models/rich_snippet/thing.rb', line 8

def name
  self.title
end

#to_json(render_childs = false) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'app/models/rich_snippet/thing.rb', line 28

def to_json(render_childs = false)
  {
    "@context": "http://schema.org",
    "@type": "Thing",
    name: name,
    description: description,
    image: image ? image.binary_url : '',
    url: url
  }.delete_if { |k, v| !v.present? }
end

#typeObject



16
17
18
# File 'app/models/rich_snippet/thing.rb', line 16

def type
  self.class.name.underscore
end

#warningsObject



39
40
41
# File 'app/models/rich_snippet/thing.rb', line 39

def warnings
  []
end