Tools

A library of utility services and concerns.

Class: SleepingKingStudios::Tools::Toolbox::ConstantMap

Parent Namespace
SleepingKingStudios::Tools::Toolbox
Inherited Classes
Module > Object
Extended Modules
Forwardable
Included Modules
Enumerable
Defined In
lib/sleeping_king_studios/tools/toolbox/constant_map.rb

Table Of Contents

Overview

Provides an enumerable interface for defining a group of constants.

Examples

UserRoles = ConstantMap.new(
  {
    GUEST: 'guest',
    USER:  'user',
    ADMIN: 'admin'
  }
)

UserRoles::GUEST
#=> 'guest'

UserRoles.user
#=> 'user'

UserRoles.all
#=> { :GUEST => 'guest', :USER => 'user', :ADMIN => 'admin' }

Back To Top

Constructor

#initialize(constants) => ConstantMap

Parameters

Returns

Back To Top

Instance Attributes

#to_h => Hash (readonly)

Also known as: all

Returns

Back To Top

Instance Methods

#each => Object

Iterates through the defined constants, yielding the name and value of each constant to the block.

Yield Parameters

#each_key => Object

Iterates through the defined constants, yielding the name of each constant to the block.

Yield Parameters

#each_pair => Object

Iterates through the defined constants, yielding the name and value of each constant to the block.

Yield Parameters

#each_value => Object

Iterates through the defined constants, yielding the value of each constant to the block.

Yield Parameters

#freeze => self

Freezes the constant map and recursively freezes every constant value.

Returns

See Also

#keys => Array

Returns

#values => Array

Returns

Back To Top


Back to Documentation | Reference | SleepingKingStudios | SleepingKingStudios::Tools | SleepingKingStudios::Tools::Toolbox