Class: Ankit::ComingCommand
Constant Summary
collapse
- DEFAULT_COUNT =
6
Constants inherited
from Command
Ankit::Command::COMMANDS
Instance Attribute Summary
Attributes inherited from Command
#args, #options, #runtime
Instance Method Summary
collapse
#last_round, #latest_round, #next_round, #round_proceeded
Methods inherited from Command
available, by_name, command_name, define_options, #initialize, option_spec
Constructor Details
This class inherits a constructor from Ankit::Command
Instance Method Details
#each_coming_events(&block) ⇒ Object
35
36
37
|
# File 'lib/ankit/coming_command.rb', line 35
def each_coming_events(&block)
name_to_events.values.sort_by(&:next_round).each(&block)
end
|
#each_coming_names(&block) ⇒ Object
26
|
# File 'lib/ankit/coming_command.rb', line 26
def each_coming_names(&block); each_coming_events { |e| block.call(e.name) }; end
|
#each_coming_paths(&block) ⇒ Object
28
29
30
31
32
33
|
# File 'lib/ankit/coming_command.rb', line 28
def each_coming_paths(&block)
each_coming_events do |event|
found = self.find_command.path_for(event.name)
block.call(found) if found
end
end
|
#each_existing_events(&block) ⇒ Object
39
40
41
|
# File 'lib/ankit/coming_command.rb', line 39
def each_existing_events(&block)
name_to_existing_events.values.sort_by(&:next_round).each(&block)
end
|
#execute ⇒ Object
21
22
23
24
|
# File 'lib/ankit/coming_command.rb', line 21
def execute()
toprint = to_enum(options[:name] ? :each_coming_names : :each_coming_paths)
toprint.take(0 <= count ? count : name_to_events.size).each { |i| runtime.stdout.print("#{i}\n") }
end
|
#find_command ⇒ Object
19
|
# File 'lib/ankit/coming_command.rb', line 19
def find_command; @find_command ||= FindCommand.new(runtime); end
|
#name_to_events ⇒ Object
43
44
45
|
# File 'lib/ankit/coming_command.rb', line 43
def name_to_events
@name_to_events ||= compute_name_to_events
end
|
#name_to_existing_events ⇒ Object
47
48
49
50
51
52
53
|
# File 'lib/ankit/coming_command.rb', line 47
def name_to_existing_events
EventTraversingCommand.new(runtime).to_enum(:each_event).reduce({}) do |a, e|
existing = a[e.name]
a[e.name] = e if existing.nil? or existing.round < e.round
a
end
end
|
#name_to_vanilla_events ⇒ Object
55
56
57
58
59
60
61
|
# File 'lib/ankit/coming_command.rb', line 55
def name_to_vanilla_events
vanilla_round = last_round
ListCommand.new(runtime).to_enum(:each_card_name).reduce({}) do |a, name|
a[name] = Event.for_card(name, "vanilla", Envelope.fresh(vanilla_round))
a
end
end
|