Class: EventReporter::Cache
- Inherits:
-
Object
- Object
- EventReporter::Cache
- Includes:
- ParseInput
- Defined in:
- lib/event_reporter/cache.rb
Instance Attribute Summary collapse
-
#queue ⇒ Object
Returns the value of attribute queue.
Instance Method Summary collapse
-
#initialize ⇒ Cache
constructor
A new instance of Cache.
- #queue_clear(leftovers) ⇒ Object
- #queue_count(leftovers) ⇒ Object
- #queue_print(leftovers) ⇒ Object
- #queue_save(leftovers) ⇒ Object
- #route_queue(input) ⇒ Object
Methods included from ParseInput
Constructor Details
#initialize ⇒ Cache
Returns a new instance of Cache.
6 7 8 |
# File 'lib/event_reporter/cache.rb', line 6 def initialize @queue = [] end |
Instance Attribute Details
#queue ⇒ Object
Returns the value of attribute queue.
3 4 5 |
# File 'lib/event_reporter/cache.rb', line 3 def queue @queue end |
Instance Method Details
#queue_clear(leftovers) ⇒ Object
24 25 26 27 |
# File 'lib/event_reporter/cache.rb', line 24 def queue_clear(leftovers) @queue = [] puts "Queue is cleared" end |
#queue_count(leftovers) ⇒ Object
20 21 22 |
# File 'lib/event_reporter/cache.rb', line 20 def queue_count(leftovers) puts "There are #{@queue.length} records in your queue" end |
#queue_print(leftovers) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/event_reporter/cache.rb', line 29 def queue_print(leftovers) if leftovers[0] == 'by' Print.queue_print_by(leftovers[1], @queue) else Print.queue_print(@queue) end end |
#queue_save(leftovers) ⇒ Object
37 38 39 40 |
# File 'lib/event_reporter/cache.rb', line 37 def queue_save(leftovers) throw(:top, "Unknown save command") if leftovers[0] != 'to' Save.route_save_to(leftovers[1], @queue) end |
#route_queue(input) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/event_reporter/cache.rb', line 10 def route_queue(input) command, leftovers = parse_input(input) method = "queue_#{command}" if respond_to? method send(method, leftovers) else throw(:top, "Unknown queue command '#{command}'") end end |