Class: ChatworkTo::Notifiers::Simple

Inherits:
Object
  • Object
show all
Defined in:
lib/chatwork_to/notifiers/simple.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Simple

Returns a new instance of Simple.



4
5
6
7
8
9
10
11
12
13
# File 'lib/chatwork_to/notifiers/simple.rb', line 4

def initialize(opts = {})
  opts = {'io' => $stdout, 'rotation' => 'weekly'}.merge(opts)
  if opts['io'].is_a?(String)
    opts['io'] = File.expand_path(opts['io'])
    FileUtils.mkdir_p(File.dirname(opts['io']))
    FileUtils.touch(opts['io']) unless File.exists?(opts['io'])
  end
  @logger = Logger.new(opts['io'], opts['rotation'])
  @logger.level = Logger::DEBUG
end

Instance Method Details

#info(message) ⇒ Object



19
20
21
# File 'lib/chatwork_to/notifiers/simple.rb', line 19

def info(message)
  @logger.info(message)
end

#notify(hash) ⇒ Object



15
16
17
# File 'lib/chatwork_to/notifiers/simple.rb', line 15

def notify(hash)
  @logger.debug({chat_list: hash['chat_list'], room: hash['room']}.inspect)
end