lib/webby/resources/db.rb
# call-seq:
#    parent_of( resource )    => resource or nil
#
#  Returns the parent page of the given resource or nil if the resource is
#  at the root of the directory structure. The parent is the "index" page
#  of the current directory or the next directory up the chain.
#
call-seq:
parent_of( resource )    => resource or nil

Returns the parent page of the given resource or nil if the resource is
at the root of the directory structure. The parent is the "index" page
of the current directory or the next directory up the chain.
call - seq : parent_of ( resource ) = > resource or nil Returns the parent page of the given resource or nil if the resource is at the root of the directory structure . The parent is the " index " page of the current directory or the next directory up the chain .
def parent_of( page )
    dir = page.dir
    loop do
      if @db.has_key? dir
        parent = @db[dir].find {|p| p.filename == 'index'}
        return parent unless parent.nil? or parent == page
      end
      break if dir.empty?
      dir = ::File.dirname(dir)
      dir = '' if dir == '.'
    end
    return
  end
def parent_of ( page ) dir = page . dir loop do if @db . has_key? dir parent = @db [ dir ] . find { | p | p . filename == 'index' } return parent unless parent . nil? or parent == page end break if dir . empty? dir = :: File . dirname ( dir ) dir = '' if dir == '.' end return end
call-seq:
parent_of( resource )    => resource or nil
call - seq : parent_of ( resource ) = > resource or nil
page