Class: Ruboty::Chinachu::Actions::Program

Inherits:
Base
  • Object
show all
Defined in:
lib/ruboty/chinachu/actions/program.rb

Constant Summary

Constants inherited from Base

Base::PROGRAM_FORMAT

Instance Method Summary collapse

Methods inherited from Base

#chinachu, #chinachu_options

Instance Method Details

#delete_reservationObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ruboty/chinachu/actions/program.rb', line 18

def delete_reservation
  begin
    program = chinachu.reserves_program(program_id)
    chinachu.delete_reserved_program(program_id)
    message.reply("Delete reservation #{summary(program, PROGRAM_FORMAT)}")
  rescue Goraku::Status404
    message.reply("Id #{program_id} is not reserved")
  rescue
    message.reply("Delete reservation #{program_id} faild")
  end
end

#reserveObject



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/ruboty/chinachu/actions/program.rb', line 6

def reserve
  begin
    chinachu.reserve_program(program_id)
    program = chinachu.program(program_id)
    message.reply("Reserved #{summary(program, PROGRAM_FORMAT)}")
  rescue Goraku::Status409
    message.reply("Id #{program_id} already reserved")
  rescue
    message.reply("Reserve #{program_id} faild")
  end
end