Class: Rbss::Parser

Inherits:
Base
  • Object
show all
Defined in:
lib/rbss/parser.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, #method_missing

Constructor Details

This class inherits a constructor from Rbss::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Rbss::Base

Instance Method Details

#evaluate(options = {}) ⇒ Object



22
23
24
25
# File 'lib/rbss/parser.rb', line 22

def evaluate(options = {})
  read
  parse
end

#p(*args, &block) ⇒ Object



27
28
29
30
31
32
# File 'lib/rbss/parser.rb', line 27

def p(*args, &block)
  @@fake_stack = caller.size
  method_missing('p', *args) do
    yield
  end
end

#parseObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rbss/parser.rb', line 10

def parse
  css = ''
  @@stack.last(@@stack.size-1).each do |pancake|
    css << "#{pancake[1]}{"
    pancake[2].properties.each do |property|
      css << "#{property.name.gsub('_','-')}:#{property.value};"
    end
    css << "}"
  end
  "<style>" + css + "</style>"
end

#read(root = defined?(Rails) ? "#{Rails.root.join('app', 'assets', 'stylesheets')}/" : nil) ⇒ Object



3
4
5
6
7
8
# File 'lib/rbss/parser.rb', line 3

def read(root = defined?(Rails) ? "#{Rails.root.join('app', 'assets', 'stylesheets')}/" : nil)
  @@files.each do |file|
    finder = "#{root}#{file}.rbss"
    eval File.open(finder).read
  end
end