Class: Stylesheet

Inherits:
Object
  • Object
show all
Defined in:
lib/unused_css/stylesheet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ Stylesheet

Returns a new instance of Stylesheet.



6
7
8
9
10
# File 'lib/unused_css/stylesheet.rb', line 6

def initialize (uri)
  @styles = Set.new
  @uri = uri
  parse_styles!
end

Instance Attribute Details

#parserObject

Returns the value of attribute parser.



4
5
6
# File 'lib/unused_css/stylesheet.rb', line 4

def parser
  @parser
end

#stylesObject

Returns the value of attribute styles.



4
5
6
# File 'lib/unused_css/stylesheet.rb', line 4

def styles
  @styles
end

#uriObject

Returns the value of attribute uri.



4
5
6
# File 'lib/unused_css/stylesheet.rb', line 4

def uri
  @uri
end

Instance Method Details

#parse_styles!Object



12
13
14
15
16
# File 'lib/unused_css/stylesheet.rb', line 12

def parse_styles!
  @parser = CssParser::Parser.new
  @parser.load_uri! @uri
  @parser.each_selector { |styles| @styles << styles }
end

#remove_pseudo_styles!Object



18
19
20
# File 'lib/unused_css/stylesheet.rb', line 18

def remove_pseudo_styles!
  @styles.delete_if { |style| style.match /::?[\w\-]+/ }
end