Class: Zakuro::Operation::Validator::SolarTerm::Direction

Inherits:
Object
  • Object
show all
Defined in:
lib/zakuro/operation/month/validator.rb

Overview

Direction 二十四節気(移動)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index:, yaml_hash: {}) ⇒ Direction

初期化

Parameters:

  • index (Integer)

    連番

  • yaml_hash (Hash<String, Object>) (defaults to: {})

    yaml

Options Hash (yaml_hash:):

  • :src (Hash)

    移動元

  • :dest (Hash)

    移動先

  • :days (String)

    中気差分



476
477
478
479
480
481
# File 'lib/zakuro/operation/month/validator.rb', line 476

def initialize(index:, yaml_hash: {})
  @index = index
  @source = Source.new(diff_index: index, yaml_hash: yaml_hash['src'])
  @destination = Destination.new(diff_index: index, yaml_hash: yaml_hash['dest'])
  @days = yaml_hash['days']
end

Instance Attribute Details

#daysString (readonly)

Returns 中気差分.

Returns:

  • (String)

    中気差分



465
466
467
# File 'lib/zakuro/operation/month/validator.rb', line 465

def days
  @days
end

#destinationDestination (readonly)

Returns 移動先.

Returns:



463
464
465
# File 'lib/zakuro/operation/month/validator.rb', line 463

def destination
  @destination
end

#indexInteger (readonly)

Returns 連番.

Returns:

  • (Integer)

    連番



459
460
461
# File 'lib/zakuro/operation/month/validator.rb', line 459

def index
  @index
end

#sourceSource (readonly)

Returns 移動元.

Returns:



461
462
463
# File 'lib/zakuro/operation/month/validator.rb', line 461

def source
  @source
end

Instance Method Details

#days?Boolean

Returns:

  • (Boolean)


483
484
485
# File 'lib/zakuro/operation/month/validator.rb', line 483

def days?
  Types.positive?(str: days)
end

#validateArray<String>

検証する

Returns:

  • (Array<String>)

    エラーメッセージ



494
495
496
497
498
499
500
501
502
503
504
505
506
# File 'lib/zakuro/operation/month/validator.rb', line 494

def validate
  failed = []

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

  failed += source.validate

  failed += destination.validate

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

  failed
end