Class: Cryptopunks::Metadata::Accessory

Inherits:
Object
  • Object
show all
Defined in:
lib/cryptopunks/structs.rb

Overview

nested class

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#limitObject (readonly)

Returns the value of attribute limit.



87
88
89
# File 'lib/cryptopunks/structs.rb', line 87

def limit
  @limit
end

#nameObject (readonly)

Returns the value of attribute name.



87
88
89
# File 'lib/cryptopunks/structs.rb', line 87

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



87
88
89
# File 'lib/cryptopunks/structs.rb', line 87

def type
  @type
end

Class Method Details

.allObject



118
# File 'lib/cryptopunks/structs.rb', line 118

def self.all() registry.values; end

.buildObject



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

.registryObject



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

#inspectObject



97
98
99
# File 'lib/cryptopunks/structs.rb', line 97

def inspect
  %Q{<Accessory "#{@name}", type: "#{@type.name}", limit: #{@limit}>}
end