Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

refactor: create public methods process_less to centralize internal l…

…ib process
  • Loading branch information...
commit 57c71a7c9d09aed4944f26629884037defeefed1 1 parent 23b2281
@thomaspierson authored
Showing with 25 additions and 6 deletions.
  1. +24 −4 css2less.rb
  2. +1 −2  script-example.rb
View
28 css2less.rb
@@ -11,6 +11,30 @@ def initialize(css)
@less = ''
end
+ def process_less
+ if @css.empty?
+ return false
+ end
+ cleanup
+ generate_tree
+ render_less
+ end
+
+ def get_less
+ return @less
+ end
+
+ def set_css(css)
+ @css = css
+ end
+
+ private
+
+ def cleanup
+ @tree = {}
+ @less = ''
+ end
+
def add_rule(tree, selectors, style)
return if style.nil? || style.empty?
if selectors.empty?
@@ -48,10 +72,6 @@ def render_less(tree=nil, indent=0)
end
end
- def get_less
- return @less
- end
-
end
end
View
3  script-example.rb
@@ -5,6 +5,5 @@
css = File.read(ARGV[0])
converter = Css2Less::Converter.new(css)
-converter.generate_tree
-converter.render_less
+converter.process_less
puts converter.get_less
Please sign in to comment.
Something went wrong with that request. Please try again.