Class: StyleScraper

Inherits:
Object
  • Object
show all
Defined in:
lib/hubdown/style_scraper.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ StyleScraper

Returns a new instance of StyleScraper.



7
8
9
10
11
12
13
14
# File 'lib/hubdown/style_scraper.rb', line 7

def initialize uri
  @uri = uri
  begin
    @page = Nokogiri::HTML( open( @uri ) )
  rescue
    # do nothing
  end
end

Instance Method Details



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/hubdown/style_scraper.rb', line 16

def get_css_links
  links = []
  if @page
    tag_links = @page.css("link").select{ |link| link['rel'] == 'stylesheet' }
    tag_links.each do |tag|
      ss = StyleSheet.new
      ss.from_tag(tag.to_s)
      links << ss
    end
  end
  links
end