util-params 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/util/params/params.rb +32 -0
- data/lib/util/params/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0756c3fc330bf6687c3168c3784b8dd747b3c914
|
4
|
+
data.tar.gz: db7b730e4a5f3901692d42db410c1232bab945ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67d8d7c97d1b64f680a4671cd2a71f2da2f3e4d3bd91945bcf5f7a6163dc5e335a73364387d14ae43926c486f83a47fbc031729fb71908b4d944cb8421ece008
|
7
|
+
data.tar.gz: bc1be57d7b4571d6357a98ddcd0776199a9cc5ed0dcbb79c0b3bd89929bca6a3ac4829b43904c90da68dba62d3056cbb278f85caa235261eebf91714d92ec669
|
data/lib/util/params/params.rb
CHANGED
@@ -51,6 +51,38 @@ module Util
|
|
51
51
|
vals
|
52
52
|
end
|
53
53
|
|
54
|
+
# パラメーター取得
|
55
|
+
def get_param_int name, default = nil, is_require = false, params = {}
|
56
|
+
|
57
|
+
val = get_param_val name, default, is_require
|
58
|
+
|
59
|
+
return nil if val.nil?
|
60
|
+
return val if val.kind_of? Integer
|
61
|
+
|
62
|
+
if /[^\d]/ =~ val
|
63
|
+
push_error "#{name.to_s} type [#{val.to_s}] != integer"
|
64
|
+
end
|
65
|
+
|
66
|
+
v = val.to_i
|
67
|
+
|
68
|
+
if params.key? :enum
|
69
|
+
for e in params[:enum]
|
70
|
+
logger.debug e
|
71
|
+
return v if e === v
|
72
|
+
end
|
73
|
+
push_error "#{name.to_s} == unknone val [#{v.to_s}]"
|
74
|
+
end
|
75
|
+
|
76
|
+
if params.key?(:min) && (v.length < params[:min])
|
77
|
+
push_error "#{name.to_s} val [#{v.to_s}] < #{params[:min].to_s}"
|
78
|
+
end
|
79
|
+
|
80
|
+
if params.key?(:max) && (v.length > params[:max])
|
81
|
+
push_error "#{name.to_s} val [#{v.to_s}] > #{params[:max].to_s}"
|
82
|
+
end
|
83
|
+
v
|
84
|
+
end
|
85
|
+
|
54
86
|
def get_param_ints name, default = [], is_require = false
|
55
87
|
vals = get_param_val name, default, is_require
|
56
88
|
return nil if vals.nil?
|
data/lib/util/params/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: util-params
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- unchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|