Class: Pharos::Channel
- Inherits:
-
Object
- Object
- Pharos::Channel
- Includes:
- HTTParty
- Defined in:
- lib/pharos/channel.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, base_uri, client = Pharos) ⇒ Channel
constructor
A new instance of Channel.
- #push(receivers, data) ⇒ Object
Constructor Details
#initialize(name, base_uri, client = Pharos) ⇒ Channel
Returns a new instance of Channel.
11 12 13 14 15 16 |
# File 'lib/pharos/channel.rb', line 11 def initialize(name, base_uri, client = Pharos) @name = name @path = base_uri + "/push/#{name}/" @client = client @auth = { username: 'pharos', password: client.secret } end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/pharos/channel.rb', line 9 def name @name end |
Instance Method Details
#push(receivers, data) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/pharos/channel.rb', line 18 def push(receivers, data) body = case data when String data # In this case we send a javascript instruction else begin MultiJson.encode(data) rescue MultiJson::DecodeError => e raise e end end = { body: { to: receivers, message: body }, basic_auth: @auth} self.class.post(@path, ) end |