Class: Commands::Block
Constant Summary collapse
- Label =
"blocked"
- MessagePrefix =
"Blocked:"
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(*args) ⇒ Block
constructor
A new instance of Block.
- #run! ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(*args) ⇒ Block
Returns a new instance of Block.
8 9 10 11 |
# File 'lib/commands/block.rb', line 8 def initialize(*args) @story_id = args.shift if args.first =~ /^(\d+)$/ super(*args) end |
Instance Method Details
#run! ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/commands/block.rb', line 13 def run! super unless story_id put "No story id was supplied and you aren't on a topic branch!" return 1 end if story.labels.to_s.include?(Label) put "Story #{story_id} is already blocked." return 0 end = [:message].to_s if .empty? loop do put "What's the reason for blocking this story?" = input.gets.chomp break unless .empty? put "" end end labels = story.labels.to_s.split(",").concat([Label]).join(",") story.update :labels => labels story.notes.create :author => full_name, :text => "#{MessagePrefix} #{}" put "Story #{story_id} has been blocked." return 0 end |