Class: Weblate::StateEnum

Inherits:
Object
  • Object
show all
Defined in:
lib/weblate/models/state_enum.rb

Constant Summary collapse

N0 =
0.freeze
N10 =
10.freeze
N20 =
20.freeze
N30 =
30.freeze
N100 =
100.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.all_varsObject



24
25
26
# File 'lib/weblate/models/state_enum.rb', line 24

def self.all_vars
  @all_vars ||= [N0, N10, N20, N30, N100].freeze
end

.build_from_hash(value) ⇒ String

Builds the enum from string

Parameters:

  • The (String)

    enum value in the form of the string

Returns:

  • (String)

    The enum value



31
32
33
# File 'lib/weblate/models/state_enum.rb', line 31

def self.build_from_hash(value)
  new.build_from_hash(value)
end

Instance Method Details

#build_from_hash(value) ⇒ String

Builds the enum from string

Parameters:

  • The (String)

    enum value in the form of the string

Returns:

  • (String)

    The enum value



38
39
40
41
# File 'lib/weblate/models/state_enum.rb', line 38

def build_from_hash(value)
  return value if StateEnum.all_vars.include?(value)
  raise "Invalid ENUM value #{value} for class #StateEnum"
end