Module: Util::Params

Defined in:
lib/util/params.rb,
lib/util/params/error.rb,
lib/util/params/params.rb,
lib/util/params/version.rb

Defined Under Namespace

Modules: Type Classes: Error

Constant Summary collapse

VERSION =
"0.2.2"

Instance Method Summary collapse

Instance Method Details

#get_array_params(key, options = {}) ⇒ Object



53
54
55
# File 'lib/util/params/params.rb', line 53

def get_array_params key, options={}
  get_params options.merge(key: key, type: Type::ARRAY)
end

#get_bool_params(key, options = {}) ⇒ Object



49
50
51
# File 'lib/util/params/params.rb', line 49

def get_bool_params key, options={}
  get_params options.merge(key: key, type: Type::BOOLEAN)
end

#get_file_params(key, options = {}) ⇒ Object



45
46
47
# File 'lib/util/params/params.rb', line 45

def get_file_params key, options={}
  get_params options.merge(key: key, type: Type::FILE)
end

#get_float_params(key, options = {}) ⇒ Object



41
42
43
# File 'lib/util/params/params.rb', line 41

def get_float_params key, options={}
  get_params options.merge(key: key, type: Type::FLOAT)
end

#get_int_params(key, options = {}) ⇒ Object



33
34
35
# File 'lib/util/params/params.rb', line 33

def get_int_params key, options={}
  get_params options.merge(key: key, type: Type::INTEGER)
end

#get_object_params(key, options = {}) ⇒ Object



57
58
59
# File 'lib/util/params/params.rb', line 57

def get_object_params key, options={}
  get_params options.merge(key: key, type: Type::OBJECT)
end

#get_params(options) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/util/params/params.rb', line 22

def get_params options
  options = options.deep_symbolize_keys

  key = options[:key]
  val = _load_val params, key, options[:default], options[:require]

  return nil if val.nil?

  _validate key, options[:type], val, options
end

#get_params_errorObject

エラーメッセージ入りスト



67
68
69
# File 'lib/util/params/params.rb', line 67

def get_params_error
  @errors.join ', '
end

#get_str_params(key, options = {}) ⇒ Object



37
38
39
# File 'lib/util/params/params.rb', line 37

def get_str_params key, options={}
  get_params options.merge(key: key, type: Type::STRING)
end

#has_params_error?Boolean

エラーがあるか

Returns:

  • (Boolean)


63
64
65
# File 'lib/util/params/params.rb', line 63

def has_params_error?
  @is_error
end

#initializeObject

コンストラクタ



5
6
7
8
9
10
# File 'lib/util/params/params.rb', line 5

def initialize
  # エラーフラグ
  @is_error = false
  # エラーリスト
  @errors = []
end