Class: Kompress::CSS

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#cssObject (readonly)

Returns the value of attribute css.



3
4
5
# File 'lib/kompress/kompress.rb', line 3

def css
  @css
end