Class: Stylesheets
- Inherits:
-
Object
- Object
- Stylesheets
- Includes:
- Enumerable
- Defined in:
- lib/unused_css/stylesheet.rb
Instance Attribute Summary collapse
-
#stylesheets ⇒ Object
Returns the value of attribute stylesheets.
Instance Method Summary collapse
- #[](uri) ⇒ Object
- #add(uris) ⇒ Object
- #already_included?(uri) ⇒ Boolean
- #each(&block) ⇒ Object
-
#initialize ⇒ Stylesheets
constructor
A new instance of Stylesheets.
- #styles ⇒ Object
Constructor Details
#initialize ⇒ Stylesheets
Returns a new instance of Stylesheets.
28 29 30 |
# File 'lib/unused_css/stylesheet.rb', line 28 def initialize @stylesheets = [] end |
Instance Attribute Details
#stylesheets ⇒ Object
Returns the value of attribute stylesheets.
26 27 28 |
# File 'lib/unused_css/stylesheet.rb', line 26 def stylesheets @stylesheets end |
Instance Method Details
#[](uri) ⇒ Object
41 42 43 |
# File 'lib/unused_css/stylesheet.rb', line 41 def [](uri) @stylesheets.find { |stylesheet| stylesheet.uri == uri } end |
#add(uris) ⇒ Object
32 33 34 35 |
# File 'lib/unused_css/stylesheet.rb', line 32 def add uris uris = Array(uris) uris.each { |uri| @stylesheets << Stylesheet.new(uri) unless already_included? uri } end |
#already_included?(uri) ⇒ Boolean
37 38 39 |
# File 'lib/unused_css/stylesheet.rb', line 37 def already_included? uri @stylesheets.any? { |stylesheet| stylesheet.uri == uri } end |
#each(&block) ⇒ Object
45 46 47 |
# File 'lib/unused_css/stylesheet.rb', line 45 def each &block @stylesheets.each &block end |
#styles ⇒ Object
49 50 51 |
# File 'lib/unused_css/stylesheet.rb', line 49 def styles @stylesheets.inject(Set.new) {|styles, stylesheet| styles.merge stylesheet.styles } end |