class Zakuro::Operation::Validator::Diffs

Diffs 総差分

Attributes

days[R]

@return [String] 日差分

index[R]

@return [Integer] 連番

month[R]

@return [Hash] 月差分

solar_term[R]

@return [Hash] 二十四節気差分

Public Class Methods

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

初期化

@param [Integer] index 連番 @param [Hash] yaml_hash yaml @option yaml_hash [Hash] :month 月差分 @option yaml_hash [Hash] :solar_term 二十四節気差分 @option yaml_hash [String] :days 日差分

# File lib/zakuro/operation/month/validator.rb, line 365
def initialize(index:, yaml_hash: {})
  @index = index
  @month = Month.new(index: index, yaml_hash: yaml_hash['month'])
  @solar_term = SolarTerm::Direction.new(index: index, yaml_hash: yaml_hash['solar_term'])
  @days = yaml_hash['days']
end

Public Instance Methods

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

検証する

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

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

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

  failed += @month.validate

  failed += @solar_term.validate

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

  failed
end