class CommandButler::Input
Attributes
input_value[R]
Public Class Methods
constant_inputs?(input_value)
click to toggle source
# File lib/command_butler/input.rb, line 15 def self.constant_inputs?(input_value) VALUE.constants.map{|c| VALUE.const_get(c)}.flatten.include? input_value end
execute_instance()
click to toggle source
# File lib/command_butler/input.rb, line 23 def self.execute_instance self.new(input_value:VALUE::EXECUTE) end
new(input_value:input_value)
click to toggle source
# File lib/command_butler/input.rb, line 11 def initialize(input_value:input_value) @input_value = input_value end
skip_instance()
click to toggle source
# File lib/command_butler/input.rb, line 19 def self.skip_instance self.new(input_value:VALUE::SKIP) end
start()
click to toggle source
# File lib/command_butler/input.rb, line 27 def self.start while(true) puts "[#{Dir.pwd}] $ execute Enter (no: n, quit: q, jump : command-number, skip : s)\n" input_value = STDIN.gets.chomp input_value = 'y' if input_value == "" # エンターの実行はyと同じにする return self.new(input_value:input_value) if constant_inputs? input_value return self.new(input_value:input_value.to_i) if input_value.to_i.nonzero? # jumpコマンド end end
Public Instance Methods
abort?()
click to toggle source
# File lib/command_butler/input.rb, line 49 def abort? (VALUE::ABORT).include? @input_value end
execute?()
click to toggle source
# File lib/command_butler/input.rb, line 41 def execute? (VALUE::EXECUTE).include? @input_value end
jump?()
click to toggle source
# File lib/command_butler/input.rb, line 37 def jump? @input_value.is_a? Integer end
skip?()
click to toggle source
# File lib/command_butler/input.rb, line 45 def skip? (VALUE::SKIP).include? @input_value end