Class: Cryptopunks::Metadata::Type

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, limit) ⇒ Type

Returns a new instance of Type.



14
15
16
17
# File 'lib/cryptopunks/structs.rb', line 14

def initialize( name, limit )
  @name  = name
  @limit = limit
end

Instance Attribute Details

#limitObject (readonly)

todo/check: use alias family or such?



12
13
14
# File 'lib/cryptopunks/structs.rb', line 12

def limit
  @limit
end

#nameObject (readonly)

todo/check: use alias family or such?



12
13
14
# File 'lib/cryptopunks/structs.rb', line 12

def name
  @name
end

Class Method Details

.allObject



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

def self.all() registry.values; end

.buildObject



26
27
28
29
30
31
32
# File 'lib/cryptopunks/structs.rb', line 26

def self.build
  TYPES.reduce( {} ) do |h, rec|
     type = Type.new( rec[:name], rec[:limit ] )
     h[ rec[:name].downcase ] = type
     h
  end
end

.find(q) ⇒ Object



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

def self.find( q ) registry[ q.to_s.downcase ]; end

.registryObject



34
35
36
37
38
# File 'lib/cryptopunks/structs.rb', line 34

def self.registry
  ## auto-build registry (hash table) lookup (by name)
  @@types ||= build
  @@types
end

Instance Method Details

#inspectObject

def to_s() @name; end



20
21
22
# File 'lib/cryptopunks/structs.rb', line 20

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