Class: Zakuro::Operation::Validator::Number

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

Overview

Number 月

Constant Summary collapse

NAME =
'number'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

初期化

Parameters:

  • index (Integer)

    連番

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

    yaml

Options Hash (yaml_hash:):

  • :src (String)

    移動元

  • :dest (String)

    移動先



657
658
659
660
661
# File 'lib/zakuro/operation/month/validator.rb', line 657

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

Instance Attribute Details

#destString (readonly)

Returns 移動先.

Returns:

  • (String)

    移動先



647
648
649
# File 'lib/zakuro/operation/month/validator.rb', line 647

def dest
  @dest
end

#indexInteger (readonly)

Returns 連番.

Returns:

  • (Integer)

    連番



643
644
645
# File 'lib/zakuro/operation/month/validator.rb', line 643

def index
  @index
end

#srcString (readonly)

Returns 移動元.

Returns:

  • (String)

    移動元



645
646
647
# File 'lib/zakuro/operation/month/validator.rb', line 645

def src
  @src
end

Instance Method Details

#dest?Boolean

Returns:

  • (Boolean)


684
685
686
# File 'lib/zakuro/operation/month/validator.rb', line 684

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

#src?Boolean

Returns:

  • (Boolean)


680
681
682
# File 'lib/zakuro/operation/month/validator.rb', line 680

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

#validateArray<String>

検証する

Returns:

  • (Array<String>)

    エラーメッセージ



668
669
670
671
672
673
674
675
676
677
678
# File 'lib/zakuro/operation/month/validator.rb', line 668

def validate
  failed = []

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

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

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

  failed
end