Class: Gish::Comment

Inherits:
Object
  • Object
show all
Includes:
DateHelpers, TerminalHelpers
Defined in:
lib/gish/presentation/comment.rb

Constant Summary

Constants included from DateHelpers

DateHelpers::A_DAY, DateHelpers::A_MONTH, DateHelpers::A_YEAR

Instance Method Summary collapse

Methods included from DateHelpers

#time_in_words

Methods included from TerminalHelpers

#bold, #console_width, #format_label, #underline

Constructor Details

#initialize(github_comment) ⇒ Comment

Returns a new instance of Comment.



6
7
8
9
10
11
# File 'lib/gish/presentation/comment.rb', line 6

def initialize(github_comment)
  @body = github_comment.body.gsub("\r\n", "\n")
  @user = github_comment.user.
  @id = github_comment.id
  @created_at = time_in_words(github_comment.created_at)
end

Instance Method Details

#to_sObject



13
14
15
16
17
# File 'lib/gish/presentation/comment.rb', line 13

def to_s
  output = "\n#{@id} #{bold(@user)} commented #{@created_at}"
  output << "\n\"#{@body}\"\n"
  output
end