Class: Comment

Inherits:
Object show all
Defined in:
lib/tdiary/io/pstore.rb

Overview

class Comment

Management a comment.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, mail, body, date = Time::now) ⇒ Comment

Returns a new instance of Comment.



71
72
73
74
# File 'lib/tdiary/io/pstore.rb', line 71

def initialize( name, mail, body, date = Time::now )
  @name, @mail, @body, @date = name, mail, body, date
  @show = true
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



69
70
71
# File 'lib/tdiary/io/pstore.rb', line 69

def body
  @body
end

#dateObject (readonly)

Returns the value of attribute date.



69
70
71
# File 'lib/tdiary/io/pstore.rb', line 69

def date
  @date
end

#mailObject (readonly)

Returns the value of attribute mail.



69
70
71
# File 'lib/tdiary/io/pstore.rb', line 69

def mail
  @mail
end

#nameObject (readonly)

Returns the value of attribute name.



69
70
71
# File 'lib/tdiary/io/pstore.rb', line 69

def name
  @name
end

Instance Method Details

#==(c) ⇒ Object



85
86
87
# File 'lib/tdiary/io/pstore.rb', line 85

def ==( c )
  (@name == c.name) and (@mail == c.mail) and (@body == c.body)
end

#shorten(len = 120) ⇒ Object



76
77
78
79
80
# File 'lib/tdiary/io/pstore.rb', line 76

def shorten( len = 120 )
  lines = NKF::nkf( "-e -m0 -f#{len}", @body.gsub( /\n/, ' ' ) ).split( /\n/ )
  lines[0].concat( '..' ) if lines[0] and lines[1]
  lines[0] || ''
end

#show=(s) ⇒ Object



83
# File 'lib/tdiary/io/pstore.rb', line 83

def show=( s ); @show = s; end

#visible?Boolean

Returns:

  • (Boolean)


82
# File 'lib/tdiary/io/pstore.rb', line 82

def visible?; @show; end