properly define the public api

This commit is contained in:
Tom Preston-Werner
2010-04-17 16:41:05 -04:00
parent 78a9396421
commit 9037b06e62
3 changed files with 47 additions and 26 deletions
+9 -7
View File
@@ -1,23 +1,25 @@
module Gollum
class File
attr_accessor :wiki, :blob, :version
# Initialize a file.
#
# wiki - The Gollum::Wiki in question.
#
# Returns a newly initialized Gollum::File.
def initialize(wiki)
self.wiki = wiki
@wiki = wiki
@blob = nil
end
# The raw contents of the page.
#
# Returns the String data.
def raw_data
self.blob.data rescue nil
@blob.data rescue nil
end
# The Grit::Commit version of the file.
attr_reader :version
#########################################################################
#
# Private
@@ -31,10 +33,10 @@ module Gollum
#
# Returns a Gollum::File or nil if the file could not be found.
def find(name, version)
commit = self.wiki.repo.commit(version)
commit = @wiki.repo.commit(version)
if blob = commit.tree / name
self.blob = blob
self.version = commit
@blob = blob
@version = commit
self
else
nil