lib/command.rb
# check place atguments, return true if is legal
check place atguments, return true if is legal
check place atguments return true if is legal
def check_place_params *args
      if args.length != 3
        throw_error "wrong number of arguments for place: (#{args.length} for 3)"
        return false
      end
      x = args[0].to_i if is_integer args[0]
      y = args[1].to_i if is_integer args[1]
      face = args[2]
      faces = Constants::FACES
      case
      when !is_integer(args[0])
        throw_error "x should be an integer"
      when !is_integer(args[1])
        throw_error "y should be and integer"
      when face.class != String
        throw_error "face should be string type"
      when x > @xmax || x < 0
        throw_error "x exceed the limitation"
      when y > @ymax || y < 0
        throw_error "y exceed the limitation"
      when faces.index(face.downcase).nil?
        throw_error "face value should be one of the #{faces}"
      else
        return true
      end 
    end
def check_place_params * args if args . length != 3 throw_error "wrong number of arguments for place: (#{args.length} for 3)" return false end x = args [ 0 ] . to_i if is_integer args [ 0 ] y = args [ 1 ] . to_i if is_integer args [ 1 ] face = args [ 2 ] faces = Constants :: FACES case when ! is_integer ( args [ 0 ] ) throw_error "x should be an integer" when ! is_integer ( args [ 1 ] ) throw_error "y should be and integer" when face . class != String throw_error "face should be string type" when x > @xmax || x < 0 throw_error "x exceed the limitation" when y > @ymax || y < 0 throw_error "y exceed the limitation" when faces . index ( face . downcase ) . nil? throw_error "face value should be one of the #{faces}" else return true end end
check place atguments, return true if is legal
check place atguments return true if is legal
# params number is 3 ...
args
<not_specific>