Class: TDiary::Comment
- Inherits:
-
Object
- Object
- TDiary::Comment
- Defined in:
- lib/tdiary/comment.rb
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(length = 120) ⇒ Object
- #show=(s) ⇒ Object
- #visible? ⇒ Boolean
Constructor Details
#initialize(name, mail, body, date = Time::now) ⇒ Comment
Returns a new instance of Comment.
9 10 11 12 |
# File 'lib/tdiary/comment.rb', line 9 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.
7 8 9 |
# File 'lib/tdiary/comment.rb', line 7 def body @body end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
7 8 9 |
# File 'lib/tdiary/comment.rb', line 7 def date @date end |
#mail ⇒ Object (readonly)
Returns the value of attribute mail.
7 8 9 |
# File 'lib/tdiary/comment.rb', line 7 def mail @mail end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/tdiary/comment.rb', line 7 def name @name end |
Instance Method Details
#==(c) ⇒ Object
27 28 29 |
# File 'lib/tdiary/comment.rb', line 27 def ==( c ) (@name == c.name) and (@mail == c.mail) and (@body == c.body) end |
#shorten(length = 120) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/tdiary/comment.rb', line 14 def shorten( length = 120 ) matched = body.gsub( /\n/, ' ' ).scan( /^.{0,#{length - 2}}/u )[0] unless $'.empty? then matched + '..' else matched end end |
#show=(s) ⇒ Object
25 |
# File 'lib/tdiary/comment.rb', line 25 def show=( s ); @show = s; end |
#visible? ⇒ Boolean
24 |
# File 'lib/tdiary/comment.rb', line 24 def visible?; @show; end |