class Zakuro::Operation::Validator::SolarTerm::Direction

Direction 二十四節気(移動)

Attributes

days[R]

@return [String] 中気差分

destination[R]

@return [Destination] 移動先

index[R]

@return [Integer] 連番

source[R]

@return [Source] 移動元

Public Class Methods

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

初期化

@param [Integer] index 連番 @param [Hash<String, Object>] yaml_hash yaml @option yaml_hash [Hash] :calc 移動元 @option yaml_hash [Hash] :actual 移動先 @option yaml_hash [String] :days 中気差分

# File lib/zakuro/operation/month/validator.rb, line 468
def initialize(index:, yaml_hash: {})
  @index = index
  @source = Source.new(diff_index: index, yaml_hash: yaml_hash['calc'])
  @destination = Destination.new(diff_index: index, yaml_hash: yaml_hash['actual'])
  @days = yaml_hash['days']
end

Public Instance Methods

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

検証する

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

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

  prefix = "[#{index}][solar_term] invalid"

  failed += @source.validate

  failed += @destination.validate

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

  failed
end