class SimpleSlack::Toggl
Constants
- TIMER_URL
- URL
Attributes
post_bot_image[RW]
post_bot_name[RW]
post_channels[RW]
post_ims[RW]
simple_client[RW]
toggl_client[RW]
Public Class Methods
new(toggl_api_token, simple_slack_client)
click to toggle source
# File lib/simple_slack/toggl.rb, line 14 def initialize(toggl_api_token, simple_slack_client) @toggl_client = TogglV8::API.new(toggl_api_token) @simple_client = simple_slack_client @post_bot_name = "slacker" @post_bot_image = ":joy:" @post_channels = [] @post_ims = [] end
Public Instance Methods
configure() { |self| ... }
click to toggle source
# File lib/simple_slack/toggl.rb, line 23 def configure yield self end
post_message(type = :regular)
click to toggle source
# File lib/simple_slack/toggl.rb, line 27 def post_message(type = :regular) case type.to_s when "morning" post_message_by(send_morning_message) when "regular" post_message_by(send_regular_message) when "noon" post_message_by(send_noon_message) when "after_noon" post_message_by(send_after_noon_message) when "night" post_message_by(send_night_message) when "dailyreport" post_message_by(send_dailyreport_message) end end
Private Instance Methods
post_message_by(text)
click to toggle source
# File lib/simple_slack/toggl.rb, line 46 def post_message_by(text) if post_channels.empty? && post_ims.empty? raise "メッセージの送り先チャンネル、IMが指定されていません" end simple_client.post.channels(to: post_channels, text: text, name: post_bot_name, icon_emoji: post_bot_image) unless post_channels.empty? simple_client.post.ims(to: post_ims, text: text, name: post_bot_name, icon_emoji: post_bot_image) unless post_ims.empty? text end