Sha256: dce1dd06e49b883c46ec2e4fa4067c3fd8e047d9d39660393a01c4c4224537df
Contents?: true
Size: 862 Bytes
Versions: 3
Compression:
Stored size: 862 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) @filtered_text = /^<p>(.*)<\/p>$/.match(@filtered_text)[1] # remove the <p> tags that markdown wraps by default end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mad_chatter-0.2.5 | lib/mad_chatter/message.rb |
mad_chatter-0.2.4 | lib/mad_chatter/message.rb |
mad_chatter-0.2.3 | lib/mad_chatter/message.rb |