class Zakuro::Operation::Validator::SolarTerm::Destination

Destination 二十四節気(移動先)

Attributes

diff_index[R]

@return [Integer] 連番

from[R]

@return [String] 移動元の月初日

index[R]

@return [String] 移動対象の二十四節気番号

zodiac_name[R]

@return [String] 十干十二支

Public Class Methods

new(diff_index:, yaml_hash: {}) click to toggle source

初期化

@param [Integer] diff_index 連番 @param [Hash<String, String>] yaml_hash yaml @option yaml_hash [String] :index 移動対象の二十四節気番号 @option yaml_hash [String] :from 移動元の月初日 @option yaml_hash [String] :zodiac_name 十干十二支

# File lib/zakuro/operation/month/validator.rb, line 586
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

Public Instance Methods

from?() click to toggle source
# File lib/zakuro/operation/month/validator.rb, line 618
def from?
  Types.western_date?(str: @from)
end
index?() click to toggle source
# File lib/zakuro/operation/month/validator.rb, line 614
def index?
  Types.positive?(str: @index)
end
validate() click to toggle source

検証する

@return [Array<String>] エラーメッセージ

# File lib/zakuro/operation/month/validator.rb, line 600
def validate
  failed = []

  prefix = "[#{@diff_index}][solar_term.actual] 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
zodiac_name?() click to toggle source
# File lib/zakuro/operation/month/validator.rb, line 622
def zodiac_name?
  Types.string?(str: @zodiac_name)
end