Class: Zakuro::Operation::Validator::SolarTerm::Destination
- Inherits:
-
Object
- Object
- Zakuro::Operation::Validator::SolarTerm::Destination
- Defined in:
- lib/zakuro/operation/month/validator.rb
Overview
Destination 二十四節気(移動先)
Instance Attribute Summary collapse
-
#diff_index ⇒ Integer
readonly
連番.
-
#from ⇒ String
readonly
移動元の月初日.
-
#index ⇒ String
readonly
移動対象の二十四節気番号.
-
#zodiac_name ⇒ String
readonly
十干十二支.
Instance Method Summary collapse
- #from? ⇒ Boolean
- #index? ⇒ Boolean
-
#initialize(diff_index:, yaml_hash: {}) ⇒ Destination
constructor
初期化.
-
#validate ⇒ Array<String>
検証する.
- #zodiac_name? ⇒ Boolean
Constructor Details
#initialize(diff_index:, yaml_hash: {}) ⇒ Destination
初期化
594 595 596 597 598 599 |
# File 'lib/zakuro/operation/month/validator.rb', line 594 def initialize(diff_index:, yaml_hash: {}) @diff_index = diff_index @index = yaml_hash['index'] @from = yaml_hash['from'] @zodiac_name = yaml_hash['zodiac_name'] end |
Instance Attribute Details
#diff_index ⇒ Integer (readonly)
Returns 連番.
577 578 579 |
# File 'lib/zakuro/operation/month/validator.rb', line 577 def diff_index @diff_index end |
#from ⇒ String (readonly)
Returns 移動元の月初日.
581 582 583 |
# File 'lib/zakuro/operation/month/validator.rb', line 581 def from @from end |
#index ⇒ String (readonly)
Returns 移動対象の二十四節気番号.
579 580 581 |
# File 'lib/zakuro/operation/month/validator.rb', line 579 def index @index end |
#zodiac_name ⇒ String (readonly)
Returns 十干十二支.
583 584 585 |
# File 'lib/zakuro/operation/month/validator.rb', line 583 def zodiac_name @zodiac_name end |
Instance Method Details
#from? ⇒ Boolean
626 627 628 |
# File 'lib/zakuro/operation/month/validator.rb', line 626 def from? Types.western_date?(str: from) end |
#index? ⇒ Boolean
622 623 624 |
# File 'lib/zakuro/operation/month/validator.rb', line 622 def index? Types.positive?(str: index) end |
#validate ⇒ Array<String>
検証する
608 609 610 611 612 613 614 615 616 617 618 619 620 |
# File 'lib/zakuro/operation/month/validator.rb', line 608 def validate failed = [] prefix = "[#{diff_index}][solar_term.dest] invalid" failed.push("#{prefix} 'index'. #{index}") unless index? failed.push("#{prefix} 'from'. #{from}") unless from? failed.push("#{prefix} 'zodiac_name'. #{zodiac_name}") unless zodiac_name? failed end |