Class: MetaInspector::Parsers::HeadLinksParser

Inherits:
Base
  • Object
show all
Defined in:
lib/meta_inspector/parsers/head_links.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from MetaInspector::Parsers::Base

Instance Method Details

#canonicalsObject



23
24
25
# File 'lib/meta_inspector/parsers/head_links.rb', line 23

def canonicals
  @canonicals ||= head_links.select { |hl| hl[:rel] == 'canonical' }
end

#feedObject

Returns the parsed document meta rss link



28
29
30
# File 'lib/meta_inspector/parsers/head_links.rb', line 28

def feed
  @feed ||= (parsed_feed('rss') || parsed_feed('atom'))
end


6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/meta_inspector/parsers/head_links.rb', line 6

def head_links
  @head_links ||= parsed.css('head link').map do |tag|
    Hash[
      tag.attributes.keys.map do |key|
        keysym = key.to_sym
        val = tag.attributes[key].value
        val = URL.absolutify(val, base_url) if keysym == :href
        [keysym, val]
      end
    ]
  end
end

#stylesheetsObject



19
20
21
# File 'lib/meta_inspector/parsers/head_links.rb', line 19

def stylesheets
  @stylesheets ||= head_links.select { |hl| hl[:rel] == 'stylesheet' }
end