Class: SRS::CLI::NextDue

Inherits:
Object
  • Object
show all
Defined in:
lib/srs/cli/next-due.rb

Instance Method Summary collapse

Instance Method Details

#help ⇒ Object



34
35
36
37
38
39
40
# File 'lib/srs/cli/next-due.rb', line 34

def help()
  puts "srs next-due\n\nPrints out the id of the next due schedule.  Prints nothing if nothing is due.\n    EOF\nend\n"

#run!(arguments) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/srs/cli/next-due.rb', line 4

def run!(arguments)
  if not SRS::Workspace.initialised? then
    puts "Current directory is not an SRS Workspace"
    return 3
  end

  ws = SRS::Workspace.new

  schedule = nil
  if File.exists? "#{ws.dotsrs}/QUEUED" then
    File.open("#{ws.dotsrs}/QUEUED", "r") do |queued_file|
      schedule = queued_file.gets
    end
  end

  if schedule == nil then
    if File.exists? "#{ws.dotsrs}/REPEAT" then
      File.open("#{ws.dotsrs}/REPEAT", "r") do |repeat_file|
        schedule = repeat_file.gets
      end
    end
  end

  if not schedule == nil then
    puts File.basename schedule
  end

  return 0
end