Class: Comment
- Inherits:
-
Object
- Object
- Comment
- Defined in:
- lib/tdiary/io/pstore.rb
Overview
class Comment
Management a comment.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#mail ⇒ Object
readonly
Returns the value of attribute mail.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(c) ⇒ Object
-
#initialize(name, mail, body, date = Time::now) ⇒ Comment
constructor
A new instance of Comment.
- #shorten(len = 120) ⇒ Object
- #show=(s) ⇒ Object
- #visible? ⇒ Boolean
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
#body ⇒ Object (readonly)
Returns the value of attribute body.
68 69 70 |
# File 'lib/tdiary/io/pstore.rb', line 68 def body @body end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
68 69 70 |
# File 'lib/tdiary/io/pstore.rb', line 68 def date @date end |
#mail ⇒ Object (readonly)
Returns the value of attribute mail.
68 69 70 |
# File 'lib/tdiary/io/pstore.rb', line 68 def mail @mail end |
#name ⇒ Object (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
81 |
# File 'lib/tdiary/io/pstore.rb', line 81 def visible?; @show; end |