Class: Oughtve::Chapter

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

Overview

Forward-declare Chapter.

Instance Method Summary collapse

Instance Method Details

#to_hashObject

Hash representation of data, including all verses.



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/oughtve/chapter.rb', line 76

def to_hash()
  closed, open = verses.partition {|verse| verse.struck }
  hash = {:open => open.map {|v| v.to_hash },
          :closed => closed.map {|v| v.to_hash }
         }

  if ended
    hash[:ended] = ended
    hash[:summary] = summary
  end

  hash
end