Class: Oughtve::Tangent
- Inherits:
-
Object
- Object
- Oughtve::Tangent
- 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
-
#current_chapter ⇒ Object
Current chapter.
-
#current_chapter=(other) ⇒ Object
Set the current chapter.
-
#to_hash ⇒ Object
Hash representation, including all Verses.
Instance Method Details
#current_chapter ⇒ Object
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_hash ⇒ Object
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 |