Class: Rack::RackSeo::Document

Inherits:
Nokogiri::HTML::Document
  • Object
show all
Defined in:
lib/rack-seo/document.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#descObject

This is a wrapper for the Nokogiri parsed page Provides some convenience methods for working with seo meta tags



5
6
7
# File 'lib/rack-seo/document.rb', line 5

def desc
  @desc
end

#keywordsObject

This is a wrapper for the Nokogiri parsed page Provides some convenience methods for working with seo meta tags



5
6
7
# File 'lib/rack-seo/document.rb', line 5

def keywords
  @keywords
end

#titleObject

This is a wrapper for the Nokogiri parsed page Provides some convenience methods for working with seo meta tags



5
6
7
# File 'lib/rack-seo/document.rb', line 5

def title
  @title
end

Class Method Details

.new(*args) ⇒ Object



8
9
10
11
# File 'lib/rack-seo/document.rb', line 8

def new(*args)
  doc = parse(args.first)
  setup_meta_tags(doc)
end

.parse(string_or_io, url = nil, encoding = 'utf-8', options = Nokogiri::XML::ParseOptions::RECOVER) ⇒ Object



13
14
15
# File 'lib/rack-seo/document.rb', line 13

def parse(string_or_io, url = nil, encoding = 'utf-8', options = Nokogiri::XML::ParseOptions::RECOVER)
  super(string_or_io, url, encoding, options)
end

Instance Method Details

#description_contentObject



34
35
36
# File 'lib/rack-seo/document.rb', line 34

def description_content
  self.description_tag.attr('content') unless description_tag.nil?
end

#description_content=(content) ⇒ Object



30
31
32
# File 'lib/rack-seo/document.rb', line 30

def description_content=(content)
  self.description_tag['content'] = content unless description_tag.nil?
end

#description_tagObject



38
39
40
# File 'lib/rack-seo/document.rb', line 38

def description_tag
  self.at_css("meta[name='description']")
end

#keywords_contentObject



46
47
48
# File 'lib/rack-seo/document.rb', line 46

def keywords_content
  keywords_tag.attr('content') unless keywords_tag.nil?
end

#keywords_content=(content) ⇒ Object



42
43
44
# File 'lib/rack-seo/document.rb', line 42

def keywords_content=(content)
  keywords_tag['content'] = content unless keywords_tag.nil?
end

#keywords_tagObject



50
51
52
# File 'lib/rack-seo/document.rb', line 50

def keywords_tag
  self.at_css("meta[name='keywords']")
end

#title_contentObject



18
19
20
# File 'lib/rack-seo/document.rb', line 18

def title_content
  self.title_tag.text
end

#title_content=(content) ⇒ Object



22
23
24
# File 'lib/rack-seo/document.rb', line 22

def title_content=(content)
  title_tag.content = content
end

#title_tagObject



26
27
28
# File 'lib/rack-seo/document.rb', line 26

def title_tag
  self.at('title')
end