Class: Less2Sass::Less::ASTHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/less2sass/less/ast_handler.rb

Overview

Handler of the Less AST.

Instance Method Summary collapse

Constructor Details

#initialize(input, target_syntax) ⇒ ASTHandler

Returns a new instance of ASTHandler.

Parameters:

  • input (File, IO)

    the root file of the Less project

  • target_syntax (Symbol)

    the specified Sass syntax for the conversion.



10
11
12
13
14
15
16
# File 'lib/less2sass/less/ast_handler.rb', line 10

def initialize(input, target_syntax)
  @target_syntax = target_syntax
  parser = Parser.new(input)
  # TODO: check syntax only if specified in the command-line options
  # parser.check_syntax unless input == $stdin
  @tree = parser.parse
end

Instance Method Details

#to_sassLess2Sass::Sass::ASTHandler

Converts the transformed Less AST to Sass AST.

Returns:



28
29
30
# File 'lib/less2sass/less/ast_handler.rb', line 28

def to_sass
  Less2Sass::Sass::ASTHandler.new(@tree.to_sass(:syntax => @target_syntax))
end

#transform_treeObject

Transforms the Less AST, so it can be converted to an equivalent Sass AST representation.



20
21
22
23
# File 'lib/less2sass/less/ast_handler.rb', line 20

def transform_tree
  @tree.transform
  self
end