Class: Belpost::Models::BatchStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/belpost/models/batch_status.rb

Overview

Helper class for batch status translations and utilities

Constant Summary collapse

TRANSLATIONS =

Mapping of status codes to their Russian translations

{
  "uncommitted" => "В обработке",
  "committed" => "Сформирована"
}.freeze

Class Method Summary collapse

Class Method Details

.allArray<String>

Get all possible statuses

Returns:

  • (Array<String>)

    Array of all possible status values



24
25
26
# File 'lib/belpost/models/batch_status.rb', line 24

def self.all
  %w[uncommitted committed]
end

.translate(status) ⇒ String

Get the Russian translation for a status

Parameters:

  • status (String)

    The status code (‘uncommitted’ or ‘committed’)

Returns:

  • (String)

    The Russian translation or the original status if not found



17
18
19
# File 'lib/belpost/models/batch_status.rb', line 17

def self.translate(status)
  TRANSLATIONS[status] || status
end

.valid?(status) ⇒ Boolean

Check if a status is valid

Parameters:

  • status (String)

    The status to check

Returns:

  • (Boolean)

    True if valid, false otherwise



32
33
34
# File 'lib/belpost/models/batch_status.rb', line 32

def self.valid?(status)
  all.include?(status)
end