Class: Campfire::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/campfire/message.rb

Overview

base message class. All messages have a message_id, timestamp, person (first name of the user generating the message), person_full_name, and body, which is the text of the message

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Message

Returns a new instance of Message.


10
11
12
13
14
15
# File 'lib/campfire/message.rb', line 10

def initialize(params)
  self.message_id = params[:id]
  self.timestamp = params[:created_at] || Time.now
  self.body = params[:body]
  self.type = params[:type].gsub(/(.*?)Message$/, '\1') if params[:type]
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body


8
9
10
# File 'lib/campfire/message.rb', line 8

def body
  @body
end

#message_idObject

Returns the value of attribute message_id


8
9
10
# File 'lib/campfire/message.rb', line 8

def message_id
  @message_id
end

#personObject

Returns the value of attribute person


8
9
10
# File 'lib/campfire/message.rb', line 8

def person
  @person
end

#person_full_nameObject

Returns the value of attribute person_full_name


8
9
10
# File 'lib/campfire/message.rb', line 8

def person_full_name
  @person_full_name
end

#timestampObject

Returns the value of attribute timestamp


8
9
10
# File 'lib/campfire/message.rb', line 8

def timestamp
  @timestamp
end

#typeObject

Returns the value of attribute type


8
9
10
# File 'lib/campfire/message.rb', line 8

def type
  @type
end

#userObject

Returns the value of attribute user


8
9
10
# File 'lib/campfire/message.rb', line 8

def user
  @user
end