Class: Iarm::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/iarm/channel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Channel

Returns a new instance of Channel.



9
10
11
12
13
14
15
# File 'lib/iarm/channel.rb', line 9

def initialize(name)
  @name = name
  @key = key
  @members = {}
  @created_at = Time.now.to_i
  @topic = nil
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



6
7
8
# File 'lib/iarm/channel.rb', line 6

def created_at
  @created_at
end

#keyObject

Returns the value of attribute key.



7
8
9
# File 'lib/iarm/channel.rb', line 7

def key
  @key
end

#membersObject

Returns the value of attribute members.



7
8
9
# File 'lib/iarm/channel.rb', line 7

def members
  @members
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/iarm/channel.rb', line 6

def name
  @name
end

#topicObject

Returns the value of attribute topic.



7
8
9
# File 'lib/iarm/channel.rb', line 7

def topic
  @topic
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/iarm/channel.rb', line 21

def empty?
  @members.empty?
end

#members_by_nameObject



25
26
27
# File 'lib/iarm/channel.rb', line 25

def members_by_name
  @members.keys.inject({}) {|hash,handle| hash[handle.name] = @members[handle] ; hash }
end

#post(handle, msg) ⇒ Object



17
18
19
# File 'lib/iarm/channel.rb', line 17

def post(handle, msg)
  handle.say(self, msg)
end