class Zakuro::Operation::Validator::SolarTerm::Source

Source 二十四節気(移動元)

Attributes

diff_index[R]

@return [Integer] 連番

index[R]

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

to[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] :to 移動先の月初日 @option yaml_hash [String] :zodiac_name 十干十二支

# File lib/zakuro/operation/month/validator.rb, line 523
def initialize(diff_index:, yaml_hash: {})
  @diff_index = diff_index
  @index = yaml_hash['index']
  @to = yaml_hash['to']
  @zodiac_name = yaml_hash['zodiac_name']
end

Public Instance Methods

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

検証する

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

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

  prefix = "[#{@diff_index}][solar_term.calc] invalid"

  failed.push("#{prefix} 'index'. #{@index}") unless index?

  failed.push("#{prefix} 'to'. #{@to}") unless to?

  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 559
def zodiac_name?
  Types.string?(str: @zodiac_name)
end