Class: Less::Engine
- Inherits:
-
Object
- Object
- Less::Engine
- Defined in:
- lib/less/engine.rb
Instance Attribute Summary collapse
-
#css ⇒ Object
readonly
Returns the value of attribute css.
-
#less ⇒ Object
readonly
Returns the value of attribute less.
Instance Method Summary collapse
-
#initialize(obj, options = {}) ⇒ Engine
constructor
A new instance of Engine.
- #parse(build = true, env = Node::Element.new) ⇒ Object (also: #to_tree)
- #prepare ⇒ Object
- #to_css ⇒ Object
Constructor Details
#initialize(obj, options = {}) ⇒ Engine
Returns a new instance of Engine.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/less/engine.rb', line 15 def initialize obj, = {} @less = if obj.is_a? File @path = File.dirname File.(obj.path) obj.read elsif obj.is_a? String obj.dup else raise ArgumentError, "argument must be an instance of File or String!" end @options = @parser = StyleSheetParser.new end |
Instance Attribute Details
#css ⇒ Object (readonly)
Returns the value of attribute css.
13 14 15 |
# File 'lib/less/engine.rb', line 13 def css @css end |
#less ⇒ Object (readonly)
Returns the value of attribute less.
13 14 15 |
# File 'lib/less/engine.rb', line 13 def less @less end |
Instance Method Details
#parse(build = true, env = Node::Element.new) ⇒ Object Also known as: to_tree
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/less/engine.rb', line 29 def parse build = true, env = Node::Element.new root = @parser.parse(self.prepare) return root unless build if root env.file = @path @tree = root.build env else raise SyntaxError, @parser.(@options[:color]) end @tree end |
#prepare ⇒ Object
49 50 51 |
# File 'lib/less/engine.rb', line 49 def prepare @less.gsub(/\r\n/, "\n").gsub(/\t/, ' ') end |
#to_css ⇒ Object
45 46 47 |
# File 'lib/less/engine.rb', line 45 def to_css @css || @css = self.parse.group.to_css end |