Class: Less::Engine
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.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/less/engine.rb', line 17 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.
15 16 17 |
# File 'lib/less/engine.rb', line 15 def css @css end |
#less ⇒ Object (readonly)
Returns the value of attribute less.
15 16 17 |
# File 'lib/less/engine.rb', line 15 def less @less end |
Instance Method Details
#parse(build = true, env = Node::Element.new) ⇒ Object Also known as: to_tree
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/less/engine.rb', line 31 def parse build = true, env = Node::Element.new root = @parser.parse(self.prepare) return root unless build if root @tree = root.build env.tap {|e| e.file = @path } else raise SyntaxError, @parser.(@options[:color]) end @tree end |
#prepare ⇒ Object
50 51 52 |
# File 'lib/less/engine.rb', line 50 def prepare @less.gsub(/\r\n/, "\n").gsub(/\t/, ' ') end |
#to_css ⇒ Object
46 47 48 |
# File 'lib/less/engine.rb', line 46 def to_css @css || @css = self.parse.group.to_css end |