Class: CG::APP

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/cg/app.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#channelObject

Returns the value of attribute channel.



8
9
10
# File 'lib/cg/app.rb', line 8

def channel
  @channel
end

#idObject

Returns the value of attribute id.



8
9
10
# File 'lib/cg/app.rb', line 8

def id
  @id
end

#messageObject

Returns the value of attribute message.



8
9
10
# File 'lib/cg/app.rb', line 8

def message
  @message
end

#responseObject

Returns the value of attribute response.



8
9
10
# File 'lib/cg/app.rb', line 8

def response
  @response
end

#secret_idObject

Returns the value of attribute secret_id.



8
9
10
# File 'lib/cg/app.rb', line 8

def secret_id
  @secret_id
end

#secret_tokenObject

Returns the value of attribute secret_token.



8
9
10
# File 'lib/cg/app.rb', line 8

def secret_token
  @secret_token
end

#sentObject

Returns the value of attribute sent.



8
9
10
# File 'lib/cg/app.rb', line 8

def sent
  @sent
end

Class Method Details

.channelObject



35
36
37
# File 'lib/cg/app.rb', line 35

def self.channel
  self.instance.channel
end

.configure {|self.instance| ... } ⇒ Object

Yields:

  • (self.instance)


10
11
12
# File 'lib/cg/app.rb', line 10

def self.configure
  yield(self.instance)
end

.idObject



14
15
16
# File 'lib/cg/app.rb', line 14

def self.id
  self.instance.id
end

.init_message {|self.instance| ... } ⇒ Object

Yields:

  • (self.instance)


26
27
28
29
# File 'lib/cg/app.rb', line 26

def self.init_message
  yield(self.instance)
  self.instance
end

.messageObject



31
32
33
# File 'lib/cg/app.rb', line 31

def self.message
  self.instance.message
end

.push(channel, message = nil) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/cg/app.rb', line 47

def self.push(channel, message = nil)
  instance = self.instance

  instance.channel = instance.perform(channel)
  instance.message = message || yield

  instance.response = CG::API.push_message_request(instance.channel, instance.message)
end

.responseObject



43
44
45
# File 'lib/cg/app.rb', line 43

def self.response
  self.instance.response
end

.secret_idObject



18
19
20
# File 'lib/cg/app.rb', line 18

def self.secret_id
  self.instance.secret_id
end

.secret_tokenObject



22
23
24
# File 'lib/cg/app.rb', line 22

def self.secret_token
  self.instance.secret_token
end

.sent?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/cg/app.rb', line 39

def self.sent?
  !!self.instance.sent
end

.statsObject



56
57
58
59
60
# File 'lib/cg/app.rb', line 56

def self.stats
  instance = self.instance

  CG::API.show_app_request(instance.id, instance.secret_id, instance.secret_token)
end

Instance Method Details

#perform(channel) ⇒ Object



70
71
72
# File 'lib/cg/app.rb', line 70

def perform(channel)
  channel[0] == "/" ? channel : "/#{channel}"
end

#pushObject



66
67
68
# File 'lib/cg/app.rb', line 66

def push
  instance.response = CG::API.push_message_request(channel, message)
end