Class: Frozen::Template::Stylesheet

Inherits:
Base
  • Object
show all
Defined in:
lib/frozen/template/stylesheet.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#file_path, #template_root_path

Instance Method Summary collapse

Methods inherited from Base

#build_file_path, #build_filename, #file_type, #relative_path, #relative_to_root, #render_to_file, #template_filename, #template_path

Constructor Details

#initialize(options = {}) ⇒ Stylesheet

Returns a new instance of Stylesheet.



10
11
12
13
14
15
16
# File 'lib/frozen/template/stylesheet.rb', line 10

def initialize(options={})
  @options = {
    :style => :compressed,
    :format => nil,
    :load_path => nil
  }.merge(options)
end

Instance Attribute Details

#file_load_pathObject

Returns the value of attribute file_load_path.



8
9
10
# File 'lib/frozen/template/stylesheet.rb', line 8

def file_load_path
  @file_load_path
end

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/frozen/template/stylesheet.rb', line 7

def options
  @options
end

Instance Method Details

#build_extensionObject



27
28
29
# File 'lib/frozen/template/stylesheet.rb', line 27

def build_extension
  ".css"
end

#build_pathObject



31
32
33
# File 'lib/frozen/template/stylesheet.rb', line 31

def build_path
  "css"
end

#contentsObject



23
24
25
# File 'lib/frozen/template/stylesheet.rb', line 23

def contents
  read_from_file(file_path)
end

#load_pathsObject



35
36
37
# File 'lib/frozen/template/stylesheet.rb', line 35

def load_paths
  [options[:load_path], file_load_path]
end

#read_from_file(file) ⇒ Object



18
19
20
21
# File 'lib/frozen/template/stylesheet.rb', line 18

def read_from_file(file)
  self.file_load_path = File.dirname(file)
  super(file)
end

#renderObject



39
40
41
42
43
44
45
# File 'lib/frozen/template/stylesheet.rb', line 39

def render
  engine = Sass::Engine.new(contents,
                            :syntax => file_type.to_sym,
                            :style => options[:style],
                            :load_paths => load_paths)
  engine.render
end