Class: Pickler::Tracker::Note

Inherits:
Abstract
  • Object
show all
Defined in:
lib/pickler/tracker/note.rb

Instance Attribute Summary collapse

Attributes inherited from Abstract

#attributes

Instance Method Summary collapse

Methods inherited from Abstract

accessor, date_reader, #id, reader

Constructor Details

#initialize(story, attributes = {}) ⇒ Note

Returns a new instance of Note.



12
13
14
15
# File 'lib/pickler/tracker/note.rb', line 12

def initialize(story, attributes = {})
  @story = story
  super(attributes)
end

Instance Attribute Details

#storyObject (readonly)

Returns the value of attribute story.



4
5
6
# File 'lib/pickler/tracker/note.rb', line 4

def story
  @story
end

Instance Method Details

#dateObject



8
9
10
# File 'lib/pickler/tracker/note.rb', line 8

def date
  noted_at && Date.new(noted_at.year, noted_at.mon, noted_at.day)
end

#inspectObject



21
22
23
# File 'lib/pickler/tracker/note.rb', line 21

def inspect
  "#<#{self.class.inspect}:#{id.inspect}, story_id: #{story.id.inspect}, date: #{date.inspect}, author: #{author.inspect}, text: #{text.inspect}>"
end

#lines(width = 79) ⇒ Object



25
26
27
# File 'lib/pickler/tracker/note.rb', line 25

def lines(width = 79)
  text.scan(/(?:.{0,#{width}}|\S+?)(?:\s|$)/).map! {|line| line.strip}[0..-2]
end

#to_xmlObject



17
18
19
# File 'lib/pickler/tracker/note.rb', line 17

def to_xml
  Pickler.hash_to_xml(:note, attributes)
end