class UnderOs::Page::Layout
Public Class Methods
new(page)
click to toggle source
# File lib/under_os/page/layout.rb, line 3 def initialize(page) @page = page build_layout_from_xib || build_layout_from_html || build_layout_from_nothing @page.view = UnderOs::UI::View.new(@page._.view) @page.view.instance_variable_set('@_tag_name', 'PAGE') end
Public Instance Methods
build_layout_from_html()
click to toggle source
# File lib/under_os/page/layout.rb, line 18 def build_layout_from_html if filename = find_layout_with_type('html') if layout = UnderOs::Parser.parse(filename) if view = UnderOs::Page::Builder.views_from(layout)[0] @page._.view = view._ @page.title = layout[0][:attrs][:title] || '' end end end end
build_layout_from_nothing()
click to toggle source
# File lib/under_os/page/layout.rb, line 29 def build_layout_from_nothing @page._.view = UIView.alloc.init @page._.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight end
build_layout_from_xib()
click to toggle source
# File lib/under_os/page/layout.rb, line 12 def build_layout_from_xib if filename = find_layout_with_type('xib') @page._.view = NSBundle.mainBundle.loadNibNamed(filename.sub(/\.xib$/, ''), owner:self, options:nil)[0] end end
find_layout_with_type(ext)
click to toggle source
# File lib/under_os/page/layout.rb, line 34 def find_layout_with_type(ext) filename = @page.class.layout || "#{@page.name}.#{ext}" filename, type = filename.match(/^(.+?)\.([a-z]+)$/).to_a.slice(1,2) if type == ext && NSBundle.mainBundle.pathForResource(filename, ofType:type) "#{filename}.#{type}" end end