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
87 88 89 |
# File 'lib/tdiary/io/pstore.rb', line 87 def ==( c ) (@name == c.name) and (@mail == c.mail) and (@body == c.body) end |
#shorten(len = 120) ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/tdiary/io/pstore.rb', line 75 def shorten( len = 120 ) matched = @body.gsub( /\n/, ' ' ).scan( /^.{0,#{len - 2}}/u )[0] if $'.nil? || $'.empty? matched else matched + '..' end end |
#show=(s) ⇒ Object
85 |
# File 'lib/tdiary/io/pstore.rb', line 85 def show=( s ); @show = s; end |
#visible? ⇒ Boolean
84 |
# File 'lib/tdiary/io/pstore.rb', line 84 def visible?; @show; end |