util-params 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc9313118431393da9fc98c2c8eb7ba94a911082
4
- data.tar.gz: ed080a887c9ceac760c4083addc59ff99789e015
3
+ metadata.gz: 0756c3fc330bf6687c3168c3784b8dd747b3c914
4
+ data.tar.gz: db7b730e4a5f3901692d42db410c1232bab945ad
5
5
  SHA512:
6
- metadata.gz: ea1ccfc3b5d559c4a2fecb3cf0a76c5efcc005e61a0e38d8eef059e3bba86be57826bc7702f52eb709e3ecebf97f076fa56bdb6f8cc4a3054c8d4bce31221ebd
7
- data.tar.gz: 99f2554ea342205b41c6b38fbda66549363e03a0c79eac402468df5485a0e121f4db4bca7e83b958f0bc17e1cbca3c8464378001e8c9c43a915d90844806d222
6
+ metadata.gz: 67d8d7c97d1b64f680a4671cd2a71f2da2f3e4d3bd91945bcf5f7a6163dc5e335a73364387d14ae43926c486f83a47fbc031729fb71908b4d944cb8421ece008
7
+ data.tar.gz: bc1be57d7b4571d6357a98ddcd0776199a9cc5ed0dcbb79c0b3bd89929bca6a3ac4829b43904c90da68dba62d3056cbb278f85caa235261eebf91714d92ec669
@@ -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?
@@ -1,5 +1,5 @@
1
1
  module Util
2
2
  module Params
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
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.0
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-09 00:00:00.000000000 Z
11
+ date: 2016-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler