Class: PushbulletRuby::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/pushbullet_ruby/channel.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Channel

Returns a new instance of Channel.



17
18
19
# File 'lib/pushbullet_ruby/channel.rb', line 17

def initialize(response)
  @body = response
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



5
6
7
# File 'lib/pushbullet_ruby/channel.rb', line 5

def body
  @body
end

Class Method Details

.from_response(response) ⇒ Object



6
7
8
9
10
11
# File 'lib/pushbullet_ruby/channel.rb', line 6

def self.from_response(response)
  response.body['subscriptions'].each_with_object([]) do |attributes, memo|
    next unless attributes['active']
    memo << new(attributes['channel'])
  end
end

Instance Method Details

#idObject



29
30
31
# File 'lib/pushbullet_ruby/channel.rb', line 29

def id
  body['iden']
end

#nameObject



25
26
27
# File 'lib/pushbullet_ruby/channel.rb', line 25

def name
  body['name']
end

#tagObject



21
22
23
# File 'lib/pushbullet_ruby/channel.rb', line 21

def tag
  body['tag']
end

#update(client: nil, params: {}) ⇒ Object



13
14
15
# File 'lib/pushbullet_ruby/channel.rb', line 13

def update(client: nil, params: {})
  client.update_subscription(channel_id: self.id, params: params)
end