Class: WatchDoge::Notification::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/watchdoge/notification/base.rb

Direct Known Subclasses

GitlabRepo

Instance Method Summary collapse

Constructor Details

#initialize(opt) ⇒ Base

Returns a new instance of Base.


13
14
15
# File 'lib/watchdoge/notification/base.rb', line 13

def initialize opt
  @message_queue = []
end

Instance Method Details

#flushObject


25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/watchdoge/notification/base.rb', line 25

def flush
  @message_queue.each do |message|
    case message
    when String
      puts message
    when ChunkyPNG::Image
      File.write 'image.png', message.to_blob
    when WatchDoge::PixelTest
      File.write 'image.png', message.diff.to_blob
    end
  end

  @message_queue = []
end

#msg_sizeObject


21
22
23
# File 'lib/watchdoge/notification/base.rb', line 21

def msg_size
  @message_queue.size
end

#push(message) ⇒ Object


17
18
19
# File 'lib/watchdoge/notification/base.rb', line 17

def push message
  @message_queue << message
end