Class: Inaba::Manipulator
- Inherits:
-
Object
- Object
- Inaba::Manipulator
- Defined in:
- lib/inaba/manipulator.rb
Overview
Manipulator of SDBM database. It manipurates SDBM database by some sub commands.
Constant Summary collapse
- ARG_ERROR =
Return codes
-1
- CMD_ERROR =
-2
- ENV_ERROR =
-3
- SUCCESS =
0
Instance Method Summary collapse
-
#initialize(argv) ⇒ Manipulator
constructor
Initialize Manipulator.
-
#ready? ⇒ Boolean
- Does Manipulator has a valid environment variable: $INABA_DB ==== Return is_ready
-
ready status.
-
#run ⇒ Object
- Run Manipulator ==== Return ret_code
-
Return code of Manipulator’s process.
Constructor Details
#initialize(argv) ⇒ Manipulator
Initialize Manipulator
23 24 25 26 |
# File 'lib/inaba/manipulator.rb', line 23 def initialize(argv) @argv = argv check_env end |
Instance Method Details
#ready? ⇒ Boolean
Does Manipulator has a valid environment variable: $INABA_DB
Return
- is_ready
-
ready status
46 47 48 |
# File 'lib/inaba/manipulator.rb', line 46 def ready? @is_ready end |
#run ⇒ Object
Run Manipulator
Return
- ret_code
-
Return code of Manipulator’s process.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/inaba/manipulator.rb', line 31 def run COMMANDS.each do |cmd_group| cmd_group.each do |cmd| ret_code = self.send("operate_#{cmd_group[0]}", @argv) if @argv[0] == cmd return ret_code if (ret_code == ARG_ERROR or ret_code == SUCCESS) end end print_unrecognizable_error return CMD_ERROR end |