Class: Troo::CommentDecorator

Inherits:
Object
  • Object
show all
Includes:
DecoratorHelpers
Defined in:
lib/troo/display/comment_decorator.rb

Instance Method Summary collapse

Methods included from DecoratorHelpers

included

Constructor Details

#initialize(comment) ⇒ CommentDecorator

Returns a new instance of CommentDecorator.



5
6
7
# File 'lib/troo/display/comment_decorator.rb', line 5

def initialize(comment)
  @comment = comment
end

Instance Method Details

#as_viewObject



9
10
11
# File 'lib/troo/display/comment_decorator.rb', line 9

def as_view
  Template.parse(self, "/../views/comment.erb")
end

#dateObject



21
22
23
# File 'lib/troo/display/comment_decorator.rb', line 21

def date
  Time.parse(comment.date).strftime("%a, %b %d at %H:%M")
end

#idObject



25
26
27
# File 'lib/troo/display/comment_decorator.rb', line 25

def id
  brackets(comment.id)
end

#member_usernameObject



13
14
15
# File 'lib/troo/display/comment_decorator.rb', line 13

def member_username
  [comment.member.username, ":"].join
end

#textObject



17
18
19
# File 'lib/troo/display/comment_decorator.rb', line 17

def text
  word_wrap(comment.text)
end