Module: Storify::StoryRepresentable

Includes:
Representable::JSON
Defined in:
lib/storify/story.rb

Instance Method Summary collapse

Instance Method Details

#to_sObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/storify/story.rb', line 37

def to_s
  published = DateTime.parse(date.published)
  published = published.nil? ? 'unpublished' : published.to_date

  out = "\n#{title}\n"
  out << ('-' * title.length.to_i) + "\n"
  out << "Date: #{published.to_s}\n"
  out << "Author: #{author.name}\n"
  out << "Link: #{permalink}\n"
  out << "\n#{description} \n"

  # serialize elements
  elements.each {|e| out << e.to_s }

  out
end