Class: SemiStatic::Stylesheet
- Defined in:
- lib/semi-static/stylesheet.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#output_dir ⇒ Object
readonly
Returns the value of attribute output_dir.
-
#output_path ⇒ Object
readonly
Returns the value of attribute output_path.
Attributes inherited from Base
#full_source_path, #site, #source_content, #source_ext, #source_metadata, #source_path
Instance Method Summary collapse
-
#initialize(site, name, options = {}) ⇒ Stylesheet
constructor
A new instance of Stylesheet.
- #load ⇒ Object
- #render ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(site, name, options = {}) ⇒ Stylesheet
Returns a new instance of Stylesheet.
5 6 7 8 9 10 11 12 13 |
# File 'lib/semi-static/stylesheet.rb', line 5 def initialize(site, name, ={}) path = "#{name}.sass" path = "#{name}.css" unless File.file?(path) super(site, path) @name, @options = name, @output_dir = 'css' @output_path = "#{output_dir}/#{name}.css" end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class SemiStatic::Base
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/semi-static/stylesheet.rb', line 3 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/semi-static/stylesheet.rb', line 3 def @options end |
#output_dir ⇒ Object (readonly)
Returns the value of attribute output_dir.
3 4 5 |
# File 'lib/semi-static/stylesheet.rb', line 3 def output_dir @output_dir end |
#output_path ⇒ Object (readonly)
Returns the value of attribute output_path.
3 4 5 |
# File 'lib/semi-static/stylesheet.rb', line 3 def output_path @output_path end |
Instance Method Details
#load ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/semi-static/stylesheet.rb', line 15 def load super Dir.chdir(File.dirname(full_source_path)) do @content = case source_ext when '.sass' Sass::Engine.new(source_content, :filename => source_path).render when '.css' source_content else raise ArgumentError, "Unsupported format: #{self.source_path}" end end end |
#render ⇒ Object
29 30 31 |
# File 'lib/semi-static/stylesheet.rb', line 29 def render @content end |