Class: Google::Hangout::Webhook::Message
- Inherits:
-
Object
- Object
- Google::Hangout::Webhook::Message
- Defined in:
- lib/google/hangout/webhook.rb
Instance Attribute Summary collapse
-
#config_path ⇒ Object
Returns the value of attribute config_path.
-
#pre_message ⇒ Object
Returns the value of attribute pre_message.
-
#response ⇒ Object
Returns the value of attribute response.
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
- #broadcast(channel, message) ⇒ Object
-
#initialize(config_path) ⇒ Message
constructor
A new instance of Message.
- #reload ⇒ Object
Constructor Details
#initialize(config_path) ⇒ Message
Returns a new instance of Message.
17 18 19 20 21 |
# File 'lib/google/hangout/webhook.rb', line 17 def initialize(config_path) self.config_path = config_path self.settings = YAML.load_file(config_path) self. = '' end |
Instance Attribute Details
#config_path ⇒ Object
Returns the value of attribute config_path.
15 16 17 |
# File 'lib/google/hangout/webhook.rb', line 15 def config_path @config_path end |
#pre_message ⇒ Object
Returns the value of attribute pre_message.
15 16 17 |
# File 'lib/google/hangout/webhook.rb', line 15 def @pre_message end |
#response ⇒ Object
Returns the value of attribute response.
15 16 17 |
# File 'lib/google/hangout/webhook.rb', line 15 def response @response end |
#settings ⇒ Object
Returns the value of attribute settings.
15 16 17 |
# File 'lib/google/hangout/webhook.rb', line 15 def settings @settings end |
Instance Method Details
#broadcast(channel, message) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/google/hangout/webhook.rb', line 27 def broadcast(channel, ) raise "Channel name #{channel.to_s} not found" if settings['channels'][channel.to_s].nil? raise "Channel url is missing" if settings['channels'][channel.to_s]['url'].nil? self.response = RestClient.post( settings['channels'][channel.to_s]['url'], { text: [, ].join }.to_json, { content_type: :json, accept: :json } ) rescue StandardError => e error = "Google Hangout Error: #{e.}" puts error raise error end |
#reload ⇒ Object
23 24 25 |
# File 'lib/google/hangout/webhook.rb', line 23 def reload self.settings = YAML.load_file(config_path) end |