Module: Zakuro::Operation::Validator::Types
- Defined in:
- lib/zakuro/operation/month/validator.rb
Overview
Types 型判定
Constant Summary collapse
- EMPTY_STRING =
'-'
- BOOLEANS =
%w[true false].freeze
Class Method Summary collapse
-
.bool?(str: '') ⇒ True, False
booleanか.
-
.empiable_bool?(str: '') ⇒ True, False
boolean(空許容)か.
-
.empiable_string?(str: '') ⇒ True, False
有効文字列(空文字許容)か.
-
.month_days?(str: '') ⇒ True, False
月差分か.
-
.num?(str: '') ⇒ True, False
数値か.
-
.positive?(str: '') ⇒ True, False
正数か.
-
.string?(str: '') ⇒ True, False
有効文字列か.
-
.western_date?(str: '') ⇒ True, False
西暦日か.
Class Method Details
.bool?(str: '') ⇒ True, False
booleanか
94 95 96 |
# File 'lib/zakuro/operation/month/validator.rb', line 94 def bool?(str: '') BOOLEANS.include?(str) end |
.empiable_bool?(str: '') ⇒ True, False
boolean(空許容)か
106 107 108 109 110 |
# File 'lib/zakuro/operation/month/validator.rb', line 106 def empiable_bool?(str: '') return true if str == EMPTY_STRING bool?(str: str) end |
.empiable_string?(str: '') ⇒ True, False
有効文字列(空文字許容)か
48 49 50 51 52 |
# File 'lib/zakuro/operation/month/validator.rb', line 48 def empiable_string?(str: '') return false unless str str.is_a?(String) end |
.month_days?(str: '') ⇒ True, False
月差分か
120 121 122 123 124 125 126 |
# File 'lib/zakuro/operation/month/validator.rb', line 120 def month_days?(str: '') return true if str == EMPTY_STRING return false unless str /^[大小]$/.match?(str) end |
.num?(str: '') ⇒ True, False
数値か
78 79 80 81 82 83 84 |
# File 'lib/zakuro/operation/month/validator.rb', line 78 def num?(str: '') return true if str == EMPTY_STRING return false unless str /^[-0-9]+$/.match?(str) end |
.positive?(str: '') ⇒ True, False
正数か
62 63 64 65 66 67 68 |
# File 'lib/zakuro/operation/month/validator.rb', line 62 def positive?(str: '') return true if str == EMPTY_STRING return false unless str /^[0-9]+$/.match?(str) end |
.string?(str: '') ⇒ True, False
有効文字列か
32 33 34 35 36 37 38 |
# File 'lib/zakuro/operation/month/validator.rb', line 32 def string?(str: '') return false if str == '' return false unless str str.is_a?(String) end |
.western_date?(str: '') ⇒ True, False
西暦日か
136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/zakuro/operation/month/validator.rb', line 136 def western_date?(str: '') return Western::Calendar.new if str == EMPTY_STRING # 1316-11-16/1317-4-13 dates = str.split('/') dates.each do |date| return true if Western::Calendar.valid_date_text(text: date) end false end |