Class: CSSminify

Inherits:
Object
  • Object
show all
Defined in:
lib/cssminify.rb,
lib/cssminify/version.rb

Constant Summary collapse

VERSION =
"1.0.2"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCSSminify

Returns a new instance of CSSminify.



8
9
# File 'lib/cssminify.rb', line 8

def initialize
end

Class Method Details

.compress(source, length = 5000) ⇒ String

Compress CSS with YUI

Parameters:

  • CSS (String, #read)

    String or IO-like object that supports #read

  • length (Integer) (defaults to: 5000)

    Maximum line length

Returns:

  • (String)

    Compressed CSS



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

def self.compress(source, length = 5000)
  self.new.compress(source, length)
end

Instance Method Details

#compress(source = '', length = 5000) ⇒ String

Compress CSS with YUI

Parameters:

  • CSS (String, #read)

    String or IO-like object that supports #read

  • length (Integer) (defaults to: 5000)

    Maximum line length

Returns:

  • (String)

    Compressed CSS



29
30
31
32
33
# File 'lib/cssminify.rb', line 29

def compress(source = '', length = 5000)
  source = source.respond_to?(:read) ? source.read : source.to_s
  
  CssCompressor.compress(source, length)
end