Sha256: adfc6968f312b6c26e8622739ac0fcf6356bbbaec2f8df05d021131ac0c3fefd

Contents?: true

Size: 694 Bytes

Versions: 38

Compression:

Stored size: 694 Bytes

Contents

#
# class Comment
#	Management a comment.
#
module TDiary
	class Comment
		attr_reader :name, :mail, :body, :date

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

		def shorten( length = 120 )
			matched = body.gsub( /\n/, ' ' ).scan( /^.{0,#{length - 2}}/u )[0]

			unless $'.empty? then
				matched + '..'
			else
				matched
			end
		end

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

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

# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
# vim: ts=3

Version data entries

38 entries across 28 versions & 1 rubygems

Version Path
tdiary-5.3.0 lib/tdiary/comment.rb
tdiary-5.2.4 lib/tdiary/comment.rb
tdiary-5.2.3 lib/tdiary/comment.rb
tdiary-5.2.2 lib/tdiary/comment.rb
tdiary-5.2.1 lib/tdiary/comment.rb
tdiary-5.2.0 lib/tdiary/comment.rb
tdiary-5.1.7 lib/tdiary/comment.rb
tdiary-5.1.6 lib/tdiary/comment.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/lib/tdiary/comment.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/lib/tdiary/comment.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/lib/tdiary/comment.rb
tdiary-5.1.5 lib/tdiary/comment.rb
tdiary-5.1.4 lib/tdiary/comment.rb
tdiary-5.1.3 lib/tdiary/comment.rb
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/tdiary-5.0.14/lib/tdiary/comment.rb
tdiary-5.1.2 lib/tdiary/comment.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/tdiary-5.0.14/lib/tdiary/comment.rb
tdiary-5.1.1 lib/tdiary/comment.rb
tdiary-5.1.0 lib/tdiary/comment.rb
tdiary-5.0.14 lib/tdiary/comment.rb