Class: Zakuro::Operation::Validator::MonthHistory
- Inherits:
-
Object
- Object
- Zakuro::Operation::Validator::MonthHistory
- Defined in:
- lib/zakuro/operation/month/validator.rb
Overview
MonthHistory 変更履歴
Instance Attribute Summary collapse
-
#id ⇒ String
readonly
ID.
-
#index ⇒ Integer
readonly
連番.
-
#modified ⇒ String
readonly
有効行.
-
#parent_id ⇒ String
readonly
親ID.
-
#western_date ⇒ String
readonly
西暦日.
Instance Method Summary collapse
- #id? ⇒ Boolean
-
#initialize(index:, yaml_hash: {}) ⇒ MonthHistory
constructor
初期化.
- #modified? ⇒ Boolean
- #parent_id? ⇒ Boolean
-
#validate ⇒ Array<String>
検証する.
- #western_date? ⇒ Boolean
Constructor Details
#initialize(index:, yaml_hash: {}) ⇒ MonthHistory
初期化
177 178 179 180 181 182 183 |
# File 'lib/zakuro/operation/month/validator.rb', line 177 def initialize(index:, yaml_hash: {}) @index = index @id = yaml_hash['id'] @parent_id = yaml_hash['parent_id'] @western_date = yaml_hash['western_date'] @modified = yaml_hash['modified'] end |
Instance Attribute Details
#id ⇒ String (readonly)
Returns ID.
159 160 161 |
# File 'lib/zakuro/operation/month/validator.rb', line 159 def id @id end |
#index ⇒ Integer (readonly)
Returns 連番.
157 158 159 |
# File 'lib/zakuro/operation/month/validator.rb', line 157 def index @index end |
#modified ⇒ String (readonly)
Returns 有効行.
165 166 167 |
# File 'lib/zakuro/operation/month/validator.rb', line 165 def modified @modified end |
#parent_id ⇒ String (readonly)
Returns 親ID.
161 162 163 |
# File 'lib/zakuro/operation/month/validator.rb', line 161 def parent_id @parent_id end |
#western_date ⇒ String (readonly)
Returns 西暦日.
163 164 165 |
# File 'lib/zakuro/operation/month/validator.rb', line 163 def western_date @western_date end |
Instance Method Details
#id? ⇒ Boolean
208 209 210 |
# File 'lib/zakuro/operation/month/validator.rb', line 208 def id? Types.string?(str: @id) end |
#modified? ⇒ Boolean
220 221 222 |
# File 'lib/zakuro/operation/month/validator.rb', line 220 def modified? Types.bool?(str: @modified) end |
#parent_id? ⇒ Boolean
212 213 214 |
# File 'lib/zakuro/operation/month/validator.rb', line 212 def parent_id? Types.string?(str: @parent_id) end |
#validate ⇒ Array<String>
検証する
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/zakuro/operation/month/validator.rb', line 192 def validate failed = [] prefix = "[#{@index}] invalid" failed.push("#{prefix} 'id'. #{@id}") unless id? failed.push("#{prefix} 'parent_id'. #{@id}") unless parent_id? failed.push("#{prefix} 'western_date'. #{@western_date}") unless western_date? failed.push("#{prefix} 'modified'. #{@modified}") unless modified? failed end |
#western_date? ⇒ Boolean
216 217 218 |
# File 'lib/zakuro/operation/month/validator.rb', line 216 def western_date? Types.western_date?(str: @western_date) end |