Class: CssMedia::Processor

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

Instance Method Summary collapse

Constructor Details

#initialize(params = { }) ⇒ Processor

Returns a new instance of Processor.



6
7
8
# File 'lib/css_media/processor.rb', line 6

def initialize(params = { })
  @params = params || { }
end

Instance Method Details

#process(css, opts = { }) ⇒ Object

Process ‘css` and return result.

Options can be:

  • ‘from` with input CSS file name. Will be used in error messages.

  • ‘to` with output CSS file name.

  • ‘map` with true to generate new source map or with previous map.



16
17
18
19
20
21
22
23
# File 'lib/css_media/processor.rb', line 16

def process(css, opts = { })
  fn = opts.fetch(:from, '').downcase
  if fn =~ /[^a-z](media[_-]only|non?[_-]media)[^a-z]/ ||
    css =~ %r{/[/*]\s*css[_-]media:?\s*(media[_-]only|non?[_-]media)[^a-z]}i
    css = send($1.gsub('-', '_'), css)
  end
  Result.new(css)
end