Class: Autoweb::Page

Inherits:
Object
  • Object
show all
Includes:
Container
Defined in:
lib/autoweb/page.rb

Instance Attribute Summary collapse

Attributes included from Container

#elements, #sub_pages

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Container

#ele, #sub, #subs

Constructor Details

#initialize(name) ⇒ Page

Returns a new instance of Page.



61
62
63
64
65
# File 'lib/autoweb/page.rb', line 61

def initialize(name)
  @name = name
  @sub_pages = {}
  @elements  = {}
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



58
59
60
# File 'lib/autoweb/page.rb', line 58

def name
  @name
end

#url_tplObject

Returns the value of attribute url_tpl.



58
59
60
# File 'lib/autoweb/page.rb', line 58

def url_tpl
  @url_tpl
end

Class Method Details

.define(name) {|page| ... } ⇒ Object

Yields:

  • (page)


67
68
69
70
71
72
# File 'lib/autoweb/page.rb', line 67

def self.define(name,&block)
  page = self.new(name)
  yield page
  self.pages[name] = page
  page
end

.pagesObject



54
55
56
# File 'lib/autoweb/page.rb', line 54

def pages
  @pages||={}
end

Instance Method Details

#parse(hash) ⇒ Object



74
75
76
# File 'lib/autoweb/page.rb', line 74

def parse(hash) 
  Parser.new(self,hash).go
end

#url(locals) ⇒ Object



78
79
80
81
82
# File 'lib/autoweb/page.rb', line 78

def url(locals) 
  OpenStruct.new(locals.merge(:url_tpl=>self.url_tpl)).instance_eval{
    eval %Q{"#{url_tpl.gsub(/"/, '\"')}"}
  }
end