broach 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/broach/room.rb +25 -1
  2. metadata +1 -1
@@ -32,10 +32,34 @@ module Broach
32
32
  options[:type] ||= :text
33
33
  Broach.session.post("room/#{id}/speak", 'message' => {
34
34
  'type' => TYPE_MAP[options[:type]],
35
- 'body' => content
35
+ 'body' => friendly_coerce_to_string(content)
36
36
  })['message']
37
37
  end
38
38
 
39
+ # Sends a sound to the room
40
+ #
41
+ # This is basically a shortcut for speak(name, :type => :sound)
42
+ def sound(name)
43
+ speak(name, :type => :sound)
44
+ end
45
+
46
+ # Sends a paste to the room
47
+ #
48
+ # This is basically a shortcut for speak(content, :type => :paste)
49
+ def paste(content)
50
+ speak(content, :type => :paste)
51
+ end
52
+
53
+ private
54
+
55
+ def friendly_coerce_to_string(content)
56
+ if content.respond_to?(:join)
57
+ content.join(' ')
58
+ else
59
+ content.to_s
60
+ end
61
+ end
62
+
39
63
  # Returns a Room instance for all rooms accessible to the authenticated user
40
64
  def self.all
41
65
  Broach.session.get('rooms')['rooms'].map do |attributes|
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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manfred Stienstra