Class: E621::Type Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rubyhexagon/type.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 type information.

Author:

  • Maxine Michalski

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, locked) ⇒ 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 Type.

Raises:

  • ArgumentError if type ID is not valid

Author:

  • Maxine Michalski

Since:

  • 1.0.0



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

def initialize(id, locked)
  unless [0, 1, 3, 4, 5].include?(id)
    raise ArgumentError, "Unkown type id: #{id}"
  end
  @id     = id.to_i
  @name   = [:general, :artist, nil, :copyright, :character, :species][@id]
  @locked = locked ? true : false
end

Instance Attribute Details

#id ⇒ Integer (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 type.

Since:

  • 1.0.0



25
26
27
# File 'lib/rubyhexagon/type.rb', line 25

def id
  @id
end

#name ⇒ String (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 type.

Since:

  • 1.0.0



28
29
30
# File 'lib/rubyhexagon/type.rb', line 28

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 Types, to give a more meaningful comparison.

Author:

  • Maxine Michalski

Since:

  • 1.0.0



55
56
57
58
# File 'lib/rubyhexagon/type.rb', line 55

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

#locked? ⇒ 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.

Check if this type is locked for the tag who has it assigned.

Author:

  • Maxine Michalski

Since:

  • 1.0.0



66
67
68
# File 'lib/rubyhexagon/type.rb', line 66

def locked?
  @locked
end