Class: Redwood::Tagger
Instance Method Summary collapse
- #apply_to_tagged(action = nil) ⇒ Object
- #drop_all_tags ⇒ Object
- #drop_tag_for(o) ⇒ Object
-
#initialize(mode, noun = "thread", plural_noun = nil) ⇒ Tagger
constructor
A new instance of Tagger.
- #tag(o) ⇒ Object
- #tagged?(o) ⇒ Boolean
- #toggle_tag_for(o) ⇒ Object
- #untag(o) ⇒ Object
Constructor Details
#initialize(mode, noun = "thread", plural_noun = nil) ⇒ Tagger
Returns a new instance of Tagger.
4 5 6 7 8 9 |
# File 'lib/sup/tagger.rb', line 4 def initialize mode, noun="thread", plural_noun=nil @mode = mode @tagged = {} @noun = noun @plural_noun = plural_noun || (@noun + "s") end |
Instance Method Details
#apply_to_tagged(action = nil) ⇒ Object
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 44 |
# File 'lib/sup/tagger.rb', line 18 def apply_to_tagged action=nil targets = @tagged.select_by_value num_tagged = targets.size if num_tagged == 0 BufferManager.flash "No tagged threads!" return end noun = num_tagged == 1 ? @noun : @plural_noun unless action c = BufferManager.ask_getch "apply to #{num_tagged} tagged #{noun}:" return if c.nil? # user cancelled action = @mode.resolve_input c end if action tagged_sym = "multi_#{action}".intern if @mode.respond_to? tagged_sym @mode.send tagged_sym, targets else BufferManager.flash "That command cannot be applied to multiple threads." end else BufferManager.flash "Unknown command #{c.to_character}." end end |
#drop_all_tags ⇒ Object
15 |
# File 'lib/sup/tagger.rb', line 15 def ; @tagged.clear; end |
#drop_tag_for(o) ⇒ Object
16 |
# File 'lib/sup/tagger.rb', line 16 def drop_tag_for o; @tagged.delete o; end |
#tag(o) ⇒ Object
13 |
# File 'lib/sup/tagger.rb', line 13 def tag o; @tagged[o] = true; end |
#tagged?(o) ⇒ Boolean
11 |
# File 'lib/sup/tagger.rb', line 11 def tagged? o; @tagged[o]; end |
#toggle_tag_for(o) ⇒ Object
12 |
# File 'lib/sup/tagger.rb', line 12 def toggle_tag_for o; @tagged[o] = !@tagged[o]; end |
#untag(o) ⇒ Object
14 |
# File 'lib/sup/tagger.rb', line 14 def untag o; @tagged[o] = false; end |