Class: Zakuro::Operation::Validator::SolarTerm::Direction
- Inherits:
-
Object
- Object
- Zakuro::Operation::Validator::SolarTerm::Direction
- Defined in:
- lib/zakuro/operation/month/validator.rb
Overview
Direction 二十四節気(移動)
Instance Attribute Summary collapse
-
#days ⇒ String
readonly
中気差分.
-
#destination ⇒ Destination
readonly
移動先.
-
#index ⇒ Integer
readonly
連番.
-
#source ⇒ Source
readonly
移動元.
Instance Method Summary collapse
- #days? ⇒ Boolean
-
#initialize(index:, yaml_hash: {}) ⇒ Direction
constructor
初期化.
-
#validate ⇒ Array<String>
検証する.
Constructor Details
#initialize(index:, yaml_hash: {}) ⇒ Direction
初期化
476 477 478 479 480 481 |
# File 'lib/zakuro/operation/month/validator.rb', line 476 def initialize(index:, yaml_hash: {}) @index = index @source = Source.new(diff_index: index, yaml_hash: yaml_hash['src']) @destination = Destination.new(diff_index: index, yaml_hash: yaml_hash['dest']) @days = yaml_hash['days'] end |
Instance Attribute Details
#days ⇒ String (readonly)
Returns 中気差分.
465 466 467 |
# File 'lib/zakuro/operation/month/validator.rb', line 465 def days @days end |
#destination ⇒ Destination (readonly)
Returns 移動先.
463 464 465 |
# File 'lib/zakuro/operation/month/validator.rb', line 463 def destination @destination end |
#index ⇒ Integer (readonly)
Returns 連番.
459 460 461 |
# File 'lib/zakuro/operation/month/validator.rb', line 459 def index @index end |
#source ⇒ Source (readonly)
Returns 移動元.
461 462 463 |
# File 'lib/zakuro/operation/month/validator.rb', line 461 def source @source end |
Instance Method Details
#days? ⇒ Boolean
483 484 485 |
# File 'lib/zakuro/operation/month/validator.rb', line 483 def days? Types.positive?(str: days) end |
#validate ⇒ Array<String>
検証する
494 495 496 497 498 499 500 501 502 503 504 505 506 |
# File 'lib/zakuro/operation/month/validator.rb', line 494 def validate failed = [] prefix = "[#{index}][solar_term] invalid" failed += source.validate failed += destination.validate failed.push("#{prefix} 'days'. #{@days}") unless days? failed end |