Class: Iarm::Channel
- Inherits:
-
Object
- Object
- Iarm::Channel
- Defined in:
- lib/iarm/channel.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#key ⇒ Object
Returns the value of attribute key.
-
#members ⇒ Object
Returns the value of attribute members.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#topic ⇒ Object
Returns the value of attribute topic.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(name) ⇒ Channel
constructor
A new instance of Channel.
- #members_by_name ⇒ Object
- #post(handle, msg) ⇒ Object
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_at ⇒ Object (readonly)
Returns the value of attribute created_at.
6 7 8 |
# File 'lib/iarm/channel.rb', line 6 def created_at @created_at end |
#key ⇒ Object
Returns the value of attribute key.
7 8 9 |
# File 'lib/iarm/channel.rb', line 7 def key @key end |
#members ⇒ Object
Returns the value of attribute members.
7 8 9 |
# File 'lib/iarm/channel.rb', line 7 def members @members end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/iarm/channel.rb', line 6 def name @name end |
#topic ⇒ Object
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
21 22 23 |
# File 'lib/iarm/channel.rb', line 21 def empty? @members.empty? end |
#members_by_name ⇒ Object
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 |