Class: Cryptopunks::Metadata::AccessoryType

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, 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

#accessoriesObject (readonly)

Returns the value of attribute accessories.



49
50
51
# File 'lib/cryptopunks/structs.rb', line 49

def accessories
  @accessories
end

#nameObject (readonly)

Returns the value of attribute name.



49
50
51
# File 'lib/cryptopunks/structs.rb', line 49

def name
  @name
end

Class Method Details

.allObject



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

def self.all() registry.values; end

.buildObject



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

.registryObject



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