Class: Comment

Inherits:
Object
  • 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.



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

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.



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

def body
  @body
end

#dateObject (readonly)

Returns the value of attribute date.



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

def date
  @date
end

#mailObject (readonly)

Returns the value of attribute mail.



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

def mail
  @mail
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#==(c) ⇒ Object



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

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

#shorten(len = 120) ⇒ Object



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

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



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

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

#visible?Boolean

Returns:

  • (Boolean)


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

def visible?; @show; end