class Zakuro::Operation::Validator::Reference

Reference 参照

Attributes

index[R]

@return [Integer] 連番

japan_date[R]

@return [String] 和暦日

number[R]

@return [String] 原文注釈番号

page[R]

@return [String] 原文頁数

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] :page 原文頁数 @option yaml_hash [String] :number 原文注釈番号 @option yaml_hash [String] :japan_date 和暦日

# File lib/zakuro/operation/month/validator.rb, line 302
def initialize(index:, yaml_hash: {})
  @index = index
  @page = yaml_hash['page']
  @number = yaml_hash['number']
  @japan_date = yaml_hash['japan_date']
end

Public Instance Methods

japan_date?() click to toggle source
# File lib/zakuro/operation/month/validator.rb, line 338
def japan_date?
  Types.string?(str: @japan_date)
end
number?() click to toggle source
# File lib/zakuro/operation/month/validator.rb, line 334
def number?
  Types.positive?(str: @number)
end
page?() click to toggle source
# File lib/zakuro/operation/month/validator.rb, line 330
def page?
  Types.positive?(str: @page)
end
validate() click to toggle source

検証する

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

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

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

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

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

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

  failed
end