Class: Stylesheet
- Inherits:
-
Object
- Object
- Stylesheet
- Defined in:
- lib/unused_css/stylesheet.rb
Instance Attribute Summary collapse
-
#parser ⇒ Object
Returns the value of attribute parser.
-
#styles ⇒ Object
Returns the value of attribute styles.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(uri) ⇒ Stylesheet
constructor
A new instance of Stylesheet.
- #parse_styles! ⇒ Object
- #remove_pseudo_styles! ⇒ Object
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
#parser ⇒ Object
Returns the value of attribute parser.
4 5 6 |
# File 'lib/unused_css/stylesheet.rb', line 4 def parser @parser end |
#styles ⇒ Object
Returns the value of attribute styles.
4 5 6 |
# File 'lib/unused_css/stylesheet.rb', line 4 def styles @styles end |
#uri ⇒ Object
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 |