Class: Cryptopunks::Metadata

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

Defined Under Namespace

Classes: Accessory, AccessoryType, Sprite, Type

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, type, accessories) ⇒ Metadata

Returns a new instance of Metadata.



133
134
135
136
137
138
# File 'lib/cryptopunks/structs.rb', line 133

def initialize( id, type, accessories )
  @id          = id
  @type        = type
  @accessories = accessories
  @birthday    = Date.new( 2017, 6, 23)   ## all 10,000 minted on June 23, 2017
end

Instance Attribute Details

#accessoriesObject (readonly)

Returns the value of attribute accessories.



128
129
130
# File 'lib/cryptopunks/structs.rb', line 128

def accessories
  @accessories
end

#birthdayObject (readonly)

Returns the value of attribute birthday.



128
129
130
# File 'lib/cryptopunks/structs.rb', line 128

def birthday
  @birthday
end

#idObject (readonly)

Returns the value of attribute id.



128
129
130
# File 'lib/cryptopunks/structs.rb', line 128

def id
  @id
end

#typeObject (readonly)

Returns the value of attribute type.



128
129
130
# File 'lib/cryptopunks/structs.rb', line 128

def type
  @type
end

Instance Method Details

#alien?Boolean

convenience helpers for “classic” (5) types

Returns:

  • (Boolean)


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

def alien?()  is_type?( 'Alien'); end

#ape?Boolean

Returns:

  • (Boolean)


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

def ape?()    is_type?( 'Ape' ); end

#female?Boolean

Returns:

  • (Boolean)


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

def female?() is_type?( 'Female' ); end

#has_attribute?(name) ⇒ Boolean Also known as: has?, include?

convenience helpers to lookup attributes

Returns:

  • (Boolean)


151
152
153
154
155
156
# File 'lib/cryptopunks/structs.rb', line 151

def has_attribute?( name )
  accessories.each do |acc|
    return true  if acc.name == name
  end
  false
end

#is_type?(name) ⇒ Boolean Also known as: is?

Returns:

  • (Boolean)


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

def is_type?( name ) @type.name == name; end

#male?Boolean

Returns:

  • (Boolean)


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

def male?()   is_type?( 'Male' ); end

#zombie?Boolean

Returns:

  • (Boolean)


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

def zombie?() is_type?( 'Zombie' ); end