Sha256: ccbed19452f36ea1d70eeb57fc06af1d0a2f9f914ee99ca71a6142b97c6cf37f
Contents?: true
Size: 902 Bytes
Versions: 4
Compression:
Stored size: 902 Bytes
Contents
module MadChatter class Message attr_accessor :type, :original_text, :filtered_text, :token, :username def initialize(type, original_text, token = nil, username = nil) @type = type @original_text = original_text @filtered_text = original_text # if filter is never called, message will be original text @token = token @username = username end # Helper method for returning filtered text. def text @filtered_text end def to_json JSON.generate({ type: @type, message: @filtered_text, username: @username, }) end def filter @filtered_text = MadChatter.markdown.render(@original_text) # remove the <p> tags that markdown wraps by default @filtered_text.sub!(/^<p>/, '') @filtered_text.sub!(/<\/p>$/, '') @filtered_text end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
mad_chatter-0.2.9 | lib/mad_chatter/message.rb |
mad_chatter-0.2.8 | lib/mad_chatter/message.rb |
mad_chatter-0.2.7 | lib/mad_chatter/message.rb |
mad_chatter-0.2.6 | lib/mad_chatter/message.rb |