Class: Rubyhexagon::Level Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rubyhexagon/level.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class to hold level information.

Author:

  • Maxine Michalski

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(level) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializer for Level a user can have. This is just to have a more Ruby like interface to it.

Parameters:

  • level (Hash)

    level a user can have.

Author:

  • Maxine Michalski

Since:

  • 1.0.0



40
41
42
43
44
45
46
47
# File 'lib/rubyhexagon/level.rb', line 40

def initialize(level)
  @id = level
  @name = if @id.between?(31, 39)
            [nil, nil, :contributor, :'former staff', :janotor][@id - 30]
          else
            %i[unactivated blocked member privileged mod admin][@id / 10]
          end
end

Instance Attribute Details

#idInteger (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns id of level.

Returns:

  • (Integer)

    id of level

Since:

  • 1.0.0



27
28
29
# File 'lib/rubyhexagon/level.rb', line 27

def id
  @id
end

#nameString (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns name of level.

Returns:

  • (String)

    name of level

Since:

  • 1.0.0



30
31
32
# File 'lib/rubyhexagon/level.rb', line 30

def name
  @name
end

Instance Method Details

#==(other) ⇒ TrueClass, FalseClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Comparison method for Level objects

Returns:

  • (TrueClass, FalseClass)

Author:

  • Maxine Michalski

Since:

  • 1.0.0



54
55
56
# File 'lib/rubyhexagon/level.rb', line 54

def ==(other)
  other.is_a?(Level) && @id == other.id && @name == other.name
end