Class: UnderOs::Parser

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

Overview

Generic templates/stylesheets parsing engine

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeParser

Returns a new instance of Parser.



10
11
12
13
# File 'lib/under_os/parser.rb', line 10

def initialize
  @css  = CSS.new
  @html = HTML.new
end

Class Method Details

.parse(*args) ⇒ Object



5
6
7
8
# File 'lib/under_os/parser.rb', line 5

def self.parse(*args)
  @inst ||= new
  @inst.parse *args
end

Instance Method Details

#parse(filename) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/under_os/parser.rb', line 15

def parse(filename)
  filepath = NSBundle.mainBundle.pathForResource(filename, ofType:nil)
  content  = filepath ? UnderOs::File.read(filepath) : ''

  case filename.split('.').pop
  when 'css'  then @css.parse(content)
  when 'html' then @html.parse(content)
  end
end