Class: Kompress::CSS
- Inherits:
-
Object
- Object
- Kompress::CSS
- Defined in:
- lib/kompress/kompress.rb
Instance Attribute Summary collapse
-
#css ⇒ Object
readonly
Returns the value of attribute css.
Instance Method Summary collapse
-
#initialize(css) ⇒ CSS
constructor
A new instance of CSS.
Constructor Details
#initialize(css) ⇒ CSS
Returns a new instance of CSS.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/kompress/kompress.rb', line 5 def initialize(css) @css = css # take out new lines @css.gsub!(/\n/,'') # take out comments @css.gsub!(/(\/\*.*?\*\/)/,' ') # take out spaces between selectors and rule blocks @css.gsub!(/([\.a-zA-Z0-9_\-\#]+?)\s*\{\s*([^\{\}\s])?/,'\1{\2') # take out spaces between rule block endings and selectors @css.gsub!(/\}\s*([\.a-zA-Z0-9_\-\#]+?)/,'}\1') # take out spaces between rules @css.gsub!(/(\:|;)(\s+)?([^;\:]+)?/,'\1\3') @css end |
Instance Attribute Details
#css ⇒ Object (readonly)
Returns the value of attribute css.
3 4 5 |
# File 'lib/kompress/kompress.rb', line 3 def css @css end |