module OnebusawaySDK::Internal::Type::Enum

def ==(other)

Returns:
  • (Boolean) -

Parameters:
  • other (Object) --

Other tags:
    Api: - public
def ==(other)
  # rubocop:disable Style/CaseEquality
  OnebusawaySDK::Internal::Type::Enum === other && other.values.to_set == values.to_set
  # rubocop:enable Style/CaseEquality
end

def ===(other) = values.include?(other)

Returns:
  • (Boolean) -

Parameters:
  • other (Object) --

Other tags:
    Api: - public
def ===(other) = values.include?(other)

def coerce(value, state:)

Returns:
  • (Symbol, Object) -

Options Hash: (**state)
  • :branched (Integer) --
  • :error (Class) --
  • :exactness (Hash{Symbol=>Object}) --
  • :strictness (Boolean) --
  • :translate_names (Boolean) --

Parameters:
  • state (Hash{Symbol=>Object}) -- .
  • value (String, Symbol, Object) --

Other tags:
    Api: - private
def coerce(value, state:)
  exactness = state.fetch(:exactness)
  val = value.is_a?(String) ? value.to_sym : value
  if values.include?(val)
    exactness[:yes] += 1
    val
  elsif values.first&.class == val.class
    exactness[:maybe] += 1
    value
  else
    exactness[:no] += 1
    state[:error] = TypeError.new("#{value.class} can't be coerced into #{self}")
    value
  end
end

def hash = values.to_set.hash

Returns:
  • (Integer) -

Other tags:
    Api: - public
def hash = values.to_set.hash

def inspect(depth: 0)

Returns:
  • (String) -

Parameters:
  • depth (Integer) --

Other tags:
    Api: - private
def inspect(depth: 0)
  if depth.positive?
    return is_a?(Module) ? super() : self.class.name
  end
  members = values.map { OnebusawaySDK::Internal::Type::Converter.inspect(_1, depth: depth.succ) }
  prefix = is_a?(Module) ? name : self.class.name
  "#{prefix}[#{members.join(' | ')}]"
end

def to_sorbet_type

Returns:
  • (Object) -

Other tags:
    Api: - private
def to_sorbet_type
  types = values.map { OnebusawaySDK::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(_1) }.uniq
  case types
  in []
    T.noreturn
  in [type]
    type
  else
    T.any(*types)
  end
end

def values = constants.map { const_get(_1) }

Returns:
  • (Array) -
def values = constants.map { const_get(_1) }