Class: Card::DirectorRegister
- Inherits:
-
Object
- Object
- Card::DirectorRegister
- Defined in:
- lib/card/director_register.rb
Class Method Summary collapse
- .act_director ⇒ Object
- .add(director) ⇒ Object
- .card_changed(old_card) ⇒ Object
- .clear ⇒ Object
- .deep_delete(director) ⇒ Object
- .delete(director) ⇒ Object
- .directors ⇒ Object
- .fetch(card, opts = {}) ⇒ Object
- .running_act? ⇒ Boolean
- .to_s ⇒ Object
Class Method Details
.act_director ⇒ Object
45 46 47 48 |
# File 'lib/card/director_register.rb', line 45 def act_director return unless DirectorRegister.act_card DirectorRegister.act_card.director end |
.add(director) ⇒ Object
70 71 72 |
# File 'lib/card/director_register.rb', line 70 def add director directors[director.card] = director end |
.card_changed(old_card) ⇒ Object
74 75 76 77 |
# File 'lib/card/director_register.rb', line 74 def card_changed old_card return unless (director = @directors.delete old_card) add director end |
.clear ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/card/director_register.rb', line 54 def clear DirectorRegister.act_card = nil directors.each_pair do |card, _dir| card.director = nil end @directors = nil end |
.deep_delete(director) ⇒ Object
85 86 87 88 89 90 |
# File 'lib/card/director_register.rb', line 85 def deep_delete director director.subdirectors.each do |subdir| deep_delete subdir end delete director end |
.delete(director) ⇒ Object
79 80 81 82 83 |
# File 'lib/card/director_register.rb', line 79 def delete director return unless @directors @directors.delete director.card director.delete end |
.directors ⇒ Object
50 51 52 |
# File 'lib/card/director_register.rb', line 50 def directors @directors ||= {} end |
.fetch(card, opts = {}) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/card/director_register.rb', line 62 def fetch card, opts={} return directors[card] if directors[card] directors.each_key do |dir_card| return dir_card.director if dir_card.name == card.name end directors[card] = Card.new_director card, opts end |
.running_act? ⇒ Boolean
92 93 94 |
# File 'lib/card/director_register.rb', line 92 def running_act? (dir = DirectorRegister.act_director) && dir.running? end |
.to_s ⇒ Object
96 97 98 |
# File 'lib/card/director_register.rb', line 96 def to_s directors.values.map(&:to_s).join "\n" end |