Class: Amiba::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/amiba/scope.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page) ⇒ Scope

Returns a new instance of Scope.



6
7
8
# File 'lib/amiba/scope.rb', line 6

def initialize(page)
  @page = page
end

Instance Attribute Details

#pageObject (readonly)

Returns the value of attribute page.



4
5
6
# File 'lib/amiba/scope.rb', line 4

def page
  @page
end

Instance Method Details

#contentObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/amiba/scope.rb', line 18

def content
  if @page.is_a? Amiba::Source::Page
    c = Amiba::Source::PageEntry.new(page)
    if c.new?
      Amiba::Tilt.new(@page).render(self)
    else
      Amiba::Tilt.new(@page).render(Amiba::Scope.new(c))
    end
  else
    Amiba::Tilt.new(@page).render(self)
  end
end

#descriptionObject



14
15
16
# File 'lib/amiba/scope.rb', line 14

def description
  page.description
end

#entriesObject



31
32
33
# File 'lib/amiba/scope.rb', line 31

def entries
  Amiba::Source::Entry
end

#full_url(frag) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/amiba/scope.rb', line 48

def full_url(frag)
  if site_url.empty?
    frag
  else
    URI.join(site_url, frag).to_s
  end
end

#partial(path, locals = {}) ⇒ Object



35
36
37
38
# File 'lib/amiba/scope.rb', line 35

def partial(path, locals={})
  p = Amiba::Source::Partial.new path
  Amiba::Tilt.new(p.filename).render(Amiba::Scope.new(p), locals)
end

#site_nameObject



40
41
42
# File 'lib/amiba/scope.rb', line 40

def site_name
   Amiba::Configuration.site_name.nil? ? "" : Amiba::Configuration.site_name
end

#site_urlObject



44
45
46
# File 'lib/amiba/scope.rb', line 44

def site_url
  Amiba::Configuration.site_name.nil? ? "" : "http://#{Amiba::Configuration.site_name}/"
end

#titleObject



10
11
12
# File 'lib/amiba/scope.rb', line 10

def title
  page.title
end