broach 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/broach.rb +1 -1
  2. data/lib/broach/room.rb +8 -1
  3. metadata +1 -1
@@ -26,7 +26,7 @@ require 'broach/exceptions'
26
26
  #
27
27
  # If you want to post multiple lines to one room, it's a good idea to create a Room instance.
28
28
  #
29
- # room = Broach.rooms.find { |room| room.name == 'Office' }
29
+ # room = Broach::Room.find_by_name('Office')
30
30
  # room.speak('Manfred just commited to the `weblog' repository')
31
31
  # room.speak("commit 4578530113cb87e1e7dbd696c376181e97d429d7\n" +
32
32
  # "Author: Manfred Stienstra <manfred@fngtps.com>\n" +
@@ -43,9 +43,16 @@ module Broach
43
43
  end
44
44
  end
45
45
 
46
- # Returns a Room instance for a room with a specific ID
46
+ # Returns a Room instance for a room with a specific ID, raises an exception when it
47
+ # can't find the room.
47
48
  def self.find(id)
48
49
  new(Broach.session.get("room/#{id.to_i}")['room'])
49
50
  end
51
+
52
+ # Returns a Room instance for a room with a specific name, returns nil when it can't find
53
+ # the room.
54
+ def self.find_by_name(name)
55
+ all.find { |room| room.name == name }
56
+ end
50
57
  end
51
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: broach
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manfred Stienstra