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
Type ID.
-
#name ⇒ String
readonly
private
Type name.
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.
-
#to_hash ⇒ Hash
private
Turn object into a hash representation of itself.
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.
Type ID
29 30 31 |
# File 'lib/rubyhexagon/tag/type.rb', line 29 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.
Type name
33 34 35 |
# File 'lib/rubyhexagon/tag/type.rb', line 33 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 |
#to_hash ⇒ Hash
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.
Turn object into a hash representation of itself
85 86 87 88 89 90 91 |
# File 'lib/rubyhexagon/tag/type.rb', line 85 def to_hash hash = {} instance_variables.each do |i| hash.store(i.to_s.sub(/^@/, '').to_sym, instance_variable_get(i)) end hash end |