class Zakuro::Catalog::Range

Range 範囲(開始日-終了日)

Attributes

last[R]

@return [Date] 終了日

start[R]

@return [Date] 開始日

Public Class Methods

new(hash: {}) click to toggle source

初期化

@param [Hash<Symbol>] hash パラメータ @option hash [Symbol] :start 開始日 @option hash [Symbol] :start 終了日

# File lib/zakuro/condition.rb, line 62
def initialize(hash: {})
  @start = hash[:start]
  @last = hash[:last]
end
validate(hash:) click to toggle source

検証する

@param [Hash<Symbol>] hash パラメータ

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

# File lib/zakuro/condition.rb, line 76
def self.validate(hash:)
  failed = []
  return failed unless hash

  unless hash.is_a?(Hash)
    failed.push("invalid range type. #{hash}. should be hash")
    return failed
  end

  failed.concat(BasisDate.validate(date: hash[:start]))
  failed.concat(BasisDate.validate(date: hash[:last]))

  failed
end