Class: Gitki::Page

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

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Page

Returns a new instance of Page.



83
84
85
86
# File 'lib/gitki.rb', line 83

def initialize(raw)
  @raw = raw
  @title, @body = split_title_and_body(raw)
end

Class Attribute Details

.dirObject (readonly)

Returns the value of attribute dir.



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

def dir
  @dir
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



81
82
83
# File 'lib/gitki.rb', line 81

def body
  @body
end

#rawObject (readonly)

Returns the value of attribute raw.



81
82
83
# File 'lib/gitki.rb', line 81

def raw
  @raw
end

#titleObject (readonly)

Returns the value of attribute title.



81
82
83
# File 'lib/gitki.rb', line 81

def title
  @title
end

Class Method Details

.find(name) ⇒ Object



67
68
69
70
71
72
73
74
# File 'lib/gitki.rb', line 67

def find(name)
  data = store[store_path(name)]
  if data
    self.new(data)
  else
    nil
  end
end

.find_allObject



59
60
61
62
63
64
65
# File 'lib/gitki.rb', line 59

def find_all
  pages = {}
  store[dir].to_hash.each do |name, text|
    pages[name] = self.new(text)
  end
  pages
end

.setup(dir) ⇒ Object



55
56
57
# File 'lib/gitki.rb', line 55

def setup(dir)
  @dir = dir
end

.store_path(name) ⇒ Object



76
77
78
# File 'lib/gitki.rb', line 76

def store_path(name)
  File.join(dir, name)
end