Class: Cryptopunks::Metadata::AccessoryType
- Inherits:
-
Object
- Object
- Cryptopunks::Metadata::AccessoryType
- Defined in:
- lib/cryptopunks/structs.rb
Overview
nested class
Instance Attribute Summary collapse
-
#accessories ⇒ Object
readonly
Returns the value of attribute accessories.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, accessories = []) ⇒ AccessoryType
constructor
A new instance of AccessoryType.
Constructor Details
#initialize(name, accessories = []) ⇒ AccessoryType
Returns a new instance of AccessoryType.
51 52 53 54 |
# File 'lib/cryptopunks/structs.rb', line 51 def initialize( name, accessories=[] ) @name = name @accessories = accessories end |
Instance Attribute Details
#accessories ⇒ Object (readonly)
Returns the value of attribute accessories.
49 50 51 |
# File 'lib/cryptopunks/structs.rb', line 49 def accessories @accessories end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
49 50 51 |
# File 'lib/cryptopunks/structs.rb', line 49 def name @name end |
Class Method Details
.all ⇒ Object
78 |
# File 'lib/cryptopunks/structs.rb', line 78 def self.all() registry.values; end |
.build ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/cryptopunks/structs.rb', line 58 def self.build ACCESSORY_TYPES.reduce( {} ) do |h, rec| type = AccessoryType.new( rec[:name] ) ## add all accessories rec[:accessories].each do |rec_acc| type.accessories << Accessory.new( rec_acc[:name], type, rec_acc[:limit].to_i ) end h[ rec[:name].downcase ] = type h end end |
.find(q) ⇒ Object
80 |
# File 'lib/cryptopunks/structs.rb', line 80 def self.find( q ) registry[ q.to_s.downcase ]; end |
.registry ⇒ Object
72 73 74 75 76 |
# File 'lib/cryptopunks/structs.rb', line 72 def self.registry ## auto-build registry (hash table) lookup (by name) @@types ||= build @@types end |