class Slackdo::Task
Public Instance Methods
add_task()
click to toggle source
# File lib/slackdo.rb, line 184 def add_task file = File.read("#{ENV['HOME']}/.slackdo/config.json") hash = JSON.parse(file) webhook = hash['slack_webhook'] notifier = Slack::Notifier.new webhook cli_category = $prompt.select('What is the category of this new task?', hash['categories']) cli_message = $prompt.ask('Type your new task:') want_note = $prompt.select('Do you want to add a note to this new task?', %w(Yes No)) cli_note = '' while want_note == 'Yes' note_text = $prompt.ask('Type your note:') cli_note << "\n`- #{note_text}`" want_note = $prompt.select('Do you want to add another note to the task?', %w(Yes No)) end note = { fallback: "This should've been a new note but looks like something went wrong...", text: cli_note, color: "gray", mrkdwn_in: ["text"] } set_message(cli_message) set_category(cli_category) set_notes(cli_note) notifier.post text: "• [#{cli_category}] #{cli_message}", attachments: [note] puts 'Item was posted to Slack...' end
get_category()
click to toggle source
# File lib/slackdo.rb, line 169 def get_category return $category end
get_message()
click to toggle source
# File lib/slackdo.rb, line 175 def get_message return $message end
get_notes()
click to toggle source
# File lib/slackdo.rb, line 181 def get_notes return $note_content end
set_category(cat)
click to toggle source
# File lib/slackdo.rb, line 166 def set_category(cat) $category = cat end
set_message(text)
click to toggle source
# File lib/slackdo.rb, line 172 def set_message(text) $message = text end
set_notes(notes)
click to toggle source
# File lib/slackdo.rb, line 178 def set_notes(notes) $note_content = notes end