Class: Roll::Amp::Style::CompiledStylesheetFile

Inherits:
Object
  • Object
show all
Defined in:
lib/roll/amp/style/compiled_stylesheet_file.rb

Overview

The stylesheet file, compiled into Rails app public directory.

Instance Method Summary collapse

Constructor Details

#initialize(app_path, stylesheet_name) ⇒ CompiledStylesheetFile

Initializes new instance of the compiled stylesheet file.

Parameters:

  • app_path (String)

    the Rails application root path.

  • stylesheet_name (String)

    the stylesheet file name.



9
10
11
# File 'lib/roll/amp/style/compiled_stylesheet_file.rb', line 9

def initialize(app_path, stylesheet_name)
  @path = CompiledStylesheetPath.new(app_path, stylesheet_name)
end

Instance Method Details

#readString

Reads content of the file. if file doesn’t exist.

Returns:

  • (String)

    the file content or empty string



16
17
18
19
20
21
22
23
24
# File 'lib/roll/amp/style/compiled_stylesheet_file.rb', line 16

def read
  full_stylesheet_path = @path.full
  if File.file?(full_stylesheet_path) &&
     File.exist?(full_stylesheet_path)
    File.read(full_stylesheet_path)
  else
    ''
  end
end