class Timetrap::Hipchat
Public Class Methods
new(api_token, room, user)
click to toggle source
# File lib/timetrap/hipchat.rb, line 7 def initialize(api_token, room, user) @client = HipChat::Client.new api_token, api_version: 'v2' @room = room @user = user end
Public Instance Methods
in()
click to toggle source
# File lib/timetrap/hipchat.rb, line 13 def in entry = Timetrap::Timer.active_entry image = shield 'started', 'green' send 'green', <<-MSG <img src="#{image}" /> <strong>#{entry.note}</strong> MSG end
out()
click to toggle source
# File lib/timetrap/hipchat.rb, line 23 def out entry = Timetrap::Timer.last_checkout duration = format_seconds entry.duration image = shield 'stopped', 'red' send 'red', <<-MSG <img src="#{image}" /> <strong>#{entry.note}</strong> after <em>#{duration}</em> MSG end
resume()
click to toggle source
# File lib/timetrap/hipchat.rb, line 34 def resume entry = Timetrap::Timer.active_entry image = shield 'resumed', 'yellow' send 'yellow', <<-MSG <img src="#{image}" /> <strong>#{entry.note}</strong> MSG end
Private Instance Methods
send(color, msg)
click to toggle source
# File lib/timetrap/hipchat.rb, line 50 def send(color, msg) @client[@room].send 'Timetrap', msg, color: color end
shield(subject = @user, status, color)
click to toggle source
# File lib/timetrap/hipchat.rb, line 46 def shield(subject = @user, status, color) "http://img.shields.io/badge/#{subject}-#{status}-#{color}.svg?style=flat" end