Class: Imageomatic::Opengraph::MetatagMapper

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::OutputSafetyHelper
Defined in:
app/models/imageomatic/opengraph/metatag_mapper.rb

Overview

Iterates recursively through an OpenGraph object and gets a bunch of metatags and keys.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ MetatagMapper

Returns a new instance of MetatagMapper.



12
13
14
# File 'app/models/imageomatic/opengraph/metatag_mapper.rb', line 12

def initialize(model)
  @model = model
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



8
9
10
# File 'app/models/imageomatic/opengraph/metatag_mapper.rb', line 8

def model
  @model
end

Instance Method Details

#metatagsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/models/imageomatic/opengraph/metatag_mapper.rb', line 16

def metatags
  Enumerator.new do |y|
    model.properties.each do |property, content|
      if content.respond_to? :properties
        MetatagMapper.new(content).metatags.each do |tag|
          y << tag
        end
      else
        y << Metatag.new(property.key, content) if content.present?
      end
    end
  end
end

#to_htmlObject



30
31
32
# File 'app/models/imageomatic/opengraph/metatag_mapper.rb', line 30

def to_html
  safe_join metatags.map(&:to_html), "\n"
end