Class: Oughtve::Tangent

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
lib/oughtve/chapter.rb,
lib/oughtve/tangent.rb

Overview

Tangents are directory-based groupings of notes.

Most of the work occurs here. Chapters and Verses are mere extras on this stage.

Instance Method Summary collapse

Instance Method Details

#current_chapterObject

Current chapter.



86
# File 'lib/oughtve/tangent.rb', line 86

def current_chapter; Chapter.get! current if current; end

#current_chapter=(other) ⇒ Object

Set the current chapter.



79
80
81
82
83
# File 'lib/oughtve/tangent.rb', line 79

def current_chapter=(other)
  other.save unless other.id  # Force ID generation.

  self.current = other.id
end

#to_hashObject

Hash representation, including all Verses.



92
93
94
95
96
97
98
99
# File 'lib/oughtve/tangent.rb', line 92

def to_hash()
  {
   :name => name,
   :dir => dir,
   :current => current_chapter.to_hash,
   :old => chapters.sort_by {|c| c.ended || Time.now }.reverse.map {|c| c.to_hash}
  }
end