class Ruboty::Toggl::Actions::Base
Constants
- NAMESPACE
- TOKEN
- WORKSPACE
Attributes
message[R]
Public Class Methods
new(message)
click to toggle source
# File lib/ruboty/toggl/actions/base.rb, line 11 def initialize(message) @message = message end
Private Instance Methods
access_token()
click to toggle source
# File lib/ruboty/toggl/actions/base.rb, line 37 def access_token @access_token ||= access_tokens[sender_name] end
access_token?()
click to toggle source
# File lib/ruboty/toggl/actions/base.rb, line 33 def access_token? !access_token.nil? end
access_tokens()
click to toggle source
# File lib/ruboty/toggl/actions/base.rb, line 17 def access_tokens message.robot.brain.data[NAMESPACE + TOKEN] ||= {} end
body()
click to toggle source
# File lib/ruboty/toggl/actions/base.rb, line 21 def body message[:description] || "" end
current_time_entry()
click to toggle source
# File lib/ruboty/toggl/actions/base.rb, line 69 def current_time_entry @current_time_entry ||= toggl.get_current_time_entry end
project()
click to toggle source
# File lib/ruboty/toggl/actions/base.rb, line 57 def project @project ||= projects.find{|h| h['name'].start_with? message[:project]} end
projects()
click to toggle source
# File lib/ruboty/toggl/actions/base.rb, line 61 def projects toggl.projects(workspace) end
reply_my_workspaces()
click to toggle source
# File lib/ruboty/toggl/actions/base.rb, line 73 def reply_my_workspaces message.reply("Select your main workspace.\n #{toggl.my_workspaces.map { |h| "`workspace #{h['id']}` #{h['name']}" }.join("\n")} ") end
require_access_token()
click to toggle source
# File lib/ruboty/toggl/actions/base.rb, line 29 def require_access_token message.reply("I don't know your toggl access token") end
require_workspace()
click to toggle source
# File lib/ruboty/toggl/actions/base.rb, line 45 def require_workspace message.reply("I don't know your default workspace.your can get your workspace list by `workspaces`") end
sender_name()
click to toggle source
# File lib/ruboty/toggl/actions/base.rb, line 25 def sender_name message.from_name end
toggl()
click to toggle source
# File lib/ruboty/toggl/actions/base.rb, line 65 def toggl @toggl ||= TogglV8::API.new(access_token) end
workspace()
click to toggle source
# File lib/ruboty/toggl/actions/base.rb, line 53 def workspace @workspace ||= workspaces[sender_name] end
workspace?()
click to toggle source
# File lib/ruboty/toggl/actions/base.rb, line 49 def workspace? !workspace.nil? end
workspaces()
click to toggle source
# File lib/ruboty/toggl/actions/base.rb, line 41 def workspaces message.robot.brain.data[NAMESPACE + WORKSPACE] ||= {} end