Class: Cryptopunks::Metadata::Accessory
- Inherits:
-
Object
- Object
- Cryptopunks::Metadata::Accessory
- Defined in:
- lib/cryptopunks/structs.rb
Overview
nested class
Instance Attribute Summary collapse
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, type, limit) ⇒ Accessory
constructor
A new instance of Accessory.
- #inspect ⇒ Object
Constructor Details
#initialize(name, type, limit) ⇒ Accessory
Returns a new instance of Accessory.
90 91 92 93 94 |
# File 'lib/cryptopunks/structs.rb', line 90 def initialize( name, type, limit ) @name = name @type = type @limit = limit end |
Instance Attribute Details
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
87 88 89 |
# File 'lib/cryptopunks/structs.rb', line 87 def limit @limit end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
87 88 89 |
# File 'lib/cryptopunks/structs.rb', line 87 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
87 88 89 |
# File 'lib/cryptopunks/structs.rb', line 87 def type @type end |
Class Method Details
.all ⇒ Object
118 |
# File 'lib/cryptopunks/structs.rb', line 118 def self.all() registry.values; end |
.build ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'lib/cryptopunks/structs.rb', line 103 def self.build AccessoryType.all.reduce( {} ) do |h, type| type.accessories.each do |acc| h[ acc.name.downcase ] = acc end h end end |
.find(q) ⇒ Object
120 |
# File 'lib/cryptopunks/structs.rb', line 120 def self.find( q ) registry[ q.to_s.downcase ]; end |
.registry ⇒ Object
112 113 114 115 116 |
# File 'lib/cryptopunks/structs.rb', line 112 def self.registry ## auto-build registry (hash table) lookup (by name) @@types ||= build @@types end |
Instance Method Details
#inspect ⇒ Object
97 98 99 |
# File 'lib/cryptopunks/structs.rb', line 97 def inspect %Q{<Accessory "#{@name}", type: "#{@type.name}", limit: #{@limit}>} end |