Class: Slackdo::Task
- Inherits:
-
Object
- Object
- Slackdo::Task
- Defined in:
- lib/slackdo.rb
Instance Method Summary collapse
- #add_task ⇒ Object
- #get_category ⇒ Object
- #get_message ⇒ Object
- #get_notes ⇒ Object
- #set_category(cat) ⇒ Object
- #set_message(text) ⇒ Object
- #set_notes(notes) ⇒ Object
Instance Method Details
#add_task ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# 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']) = $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_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 ⇒ Object
169 170 171 |
# File 'lib/slackdo.rb', line 169 def get_category return $category end |
#get_message ⇒ Object
175 176 177 |
# File 'lib/slackdo.rb', line 175 def return end |
#get_notes ⇒ Object
181 182 183 |
# File 'lib/slackdo.rb', line 181 def get_notes return $note_content end |
#set_category(cat) ⇒ Object
166 167 168 |
# File 'lib/slackdo.rb', line 166 def set_category(cat) $category = cat end |
#set_message(text) ⇒ Object
172 173 174 |
# File 'lib/slackdo.rb', line 172 def (text) = text end |
#set_notes(notes) ⇒ Object
178 179 180 |
# File 'lib/slackdo.rb', line 178 def set_notes(notes) $note_content = notes end |