Class: Zakuro::Operation::Validator::Days

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

Overview

Days 月日数(大小)

Constant Summary collapse

NAME =
'days'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

初期化

Parameters:

  • index (Integer)

    連番

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

    yaml

Options Hash (yaml_hash:):

  • :src (String)

    移動元

  • :dest (String)

    移動先



763
764
765
766
767
# File 'lib/zakuro/operation/month/validator.rb', line 763

def initialize(index:, yaml_hash: {})
  @index = index
  @src = yaml_hash['src']
  @dest = yaml_hash['dest']
end

Instance Attribute Details

#destString (readonly)

Returns 移動先.

Returns:

  • (String)

    移動先



753
754
755
# File 'lib/zakuro/operation/month/validator.rb', line 753

def dest
  @dest
end

#indexInteger (readonly)

Returns 連番.

Returns:

  • (Integer)

    連番



749
750
751
# File 'lib/zakuro/operation/month/validator.rb', line 749

def index
  @index
end

#srcString (readonly)

Returns 移動元.

Returns:

  • (String)

    移動元



751
752
753
# File 'lib/zakuro/operation/month/validator.rb', line 751

def src
  @src
end

Instance Method Details

#dest?Boolean

Returns:

  • (Boolean)


790
791
792
# File 'lib/zakuro/operation/month/validator.rb', line 790

def dest?
  Types.month_days?(str: dest)
end

#src?Boolean

Returns:

  • (Boolean)


786
787
788
# File 'lib/zakuro/operation/month/validator.rb', line 786

def src?
  Types.month_days?(str: src)
end

#validateArray<String>

検証する

Returns:

  • (Array<String>)

    エラーメッセージ



774
775
776
777
778
779
780
781
782
783
784
# File 'lib/zakuro/operation/month/validator.rb', line 774

def validate
  failed = []

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

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

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

  failed
end