Class: Rubyhexagon::Tag::Type Private
- Inherits:
-
Object
- Object
- Rubyhexagon::Tag::Type
- Defined in:
- lib/rubyhexagon/tag/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.
Instance Attribute Summary collapse
-
#id ⇒ Integer
readonly
private
Id of type.
-
#name ⇒ String
readonly
private
Name of type.
Instance Method Summary collapse
-
#==(other) ⇒ TrueClass, FalseClass
private
Comparison method for Types, to give a more meaningful comparison.
-
#initialize(type) ⇒ Object
constructor
private
Initializer for Type.
-
#locked? ⇒ TrueClass, FalseClass
private
Check if this type is locked for the tag who has it assigned.
Constructor Details
#initialize(type) ⇒ 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.
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rubyhexagon/tag/type.rb', line 44 def initialize(type) unless type.is_a?(Hash) raise ArgumentError, "#{type.class} is not a Hash" end raise ArgumentError, 'Missing :locked key' if type[:locked].nil? unless [0, 1, 3, 4, 5].include?(type[:id]) raise InvalidIDError, "Unkown type id: #{type[:id].inspect}" end @id = type[:id] @name = [:general, :artist, nil, :copyright, :character, :species][@id] @locked = type[: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.
28 29 30 |
# File 'lib/rubyhexagon/tag/type.rb', line 28 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.
31 32 33 |
# File 'lib/rubyhexagon/tag/type.rb', line 31 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.
63 64 65 66 |
# File 'lib/rubyhexagon/tag/type.rb', line 63 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.
74 75 76 |
# File 'lib/rubyhexagon/tag/type.rb', line 74 def locked? @locked end |