class Zakuro::Operation::Validator::Number

Number

Constants

NAME

Attributes

actual[R]

@return [String] 運用

calc[R]

@return [String] 計算

index[R]

@return [Integer] 連番

Public Class Methods

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

初期化

@param [Integer] index 連番 @param [Hash<String, String>] yaml_hash yaml @option yaml_hash [String] :calc 計算 @option yaml_hash [String] :actual 運用

# File lib/zakuro/operation/month/validator.rb, line 649
def initialize(index:, yaml_hash: {})
  @index = index
  @calc = yaml_hash['calc']
  @actual = yaml_hash['actual']
end

Public Instance Methods

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

検証する

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

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

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

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

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

  failed
end