Sha256: 06ca9860260d86948f56cc19dc57afc4a0e660af6f8430b1980e4f7734ea739f

Contents?: true

Size: 459 Bytes

Versions: 1

Compression:

Stored size: 459 Bytes

Contents

module LightGBM
  module Utils
    private

    def check_result(err)
      raise LightGBM::Error, FFI.LGBM_GetLastError if err != 0
    end

    # remove spaces in keys and values to prevent injection
    def params_str(params)
      (params || {}).map { |k, v| [check_param(k.to_s), check_param(v.to_s)].join("=") }.join(" ")
    end

    def check_param(v)
      raise ArgumentError, "Invalid parameter" if /[[:space:]]/.match(v)
      v
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lightgbm-0.1.1 lib/lightgbm/utils.rb