Class: Snatch::Clean::CSS

Inherits:
Object
  • Object
show all
Defined in:
lib/snatch/clean/css.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc, working_directory) ⇒ CSS

Returns a new instance of CSS.



6
7
8
9
# File 'lib/snatch/clean/css.rb', line 6

def initialize(doc, working_directory)
  self.doc               = doc
  self.working_directory = working_directory
end

Instance Attribute Details

#docObject

Returns the value of attribute doc.



4
5
6
# File 'lib/snatch/clean/css.rb', line 4

def doc
  @doc
end

#working_directoryObject

Returns the value of attribute working_directory.



4
5
6
# File 'lib/snatch/clean/css.rb', line 4

def working_directory
  @working_directory
end

Class Method Details

.update(nokogiri_doc, working_directory = nil) ⇒ Object



11
12
13
# File 'lib/snatch/clean/css.rb', line 11

def self.update(nokogiri_doc, working_directory = nil)
  new(nokogiri_doc, working_directory).update
end

Instance Method Details

#updateObject



15
16
17
18
19
20
# File 'lib/snatch/clean/css.rb', line 15

def update
  doc.css('link[rel=stylesheet]').each do |stylesheet_node|
    stylesheet_node['href'] = rewrite_href(stylesheet_node['href'])
  end
  doc
end