Class: Cryptopunks::ImageComposite
- Inherits:
-
Pixelart::ImageComposite
- Object
- Pixelart::ImageComposite
- Cryptopunks::ImageComposite
- Defined in:
- lib/cryptopunks/composite.rb
Overview
note: was Image::Composite
Constant Summary collapse
- PUNK_HASH =
'ac39af4793119ee46bbff351d8cb6b5f23da60222126add4268e261199a2921b'
- PUNK_HEIGHT =
24
- PUNK_WIDTH =
24
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args, width: PUNK_WIDTH, height: PUNK_HEIGHT) ⇒ ImageComposite
constructor
A new instance of ImageComposite.
Constructor Details
#initialize(*args, width: PUNK_WIDTH, height: PUNK_HEIGHT) ⇒ ImageComposite
Returns a new instance of ImageComposite.
32 33 34 35 |
# File 'lib/cryptopunks/composite.rb', line 32 def initialize( *args, width: PUNK_WIDTH, height: PUNK_HEIGHT ) super end |
Class Method Details
.read(path = './punks.png', width: PUNK_WIDTH, height: PUNK_HEIGHT) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cryptopunks/composite.rb', line 16 def self.read( path='./punks.png', width: PUNK_WIDTH, height: PUNK_HEIGHT ) data = File.open( path, 'rb' ) { |f| f.read } hexdigest = sha256( data ) ## check sha256 checksum if hexdigest == PUNK_HASH puts " >#{hexdigest}< SHA256 hash matching" puts " ✓ True Official Genuine CryptoPunks™ verified" else puts " ✓ True Official Genuine Yes, You Can! Punks Not Dead™ verified" end img = ChunkyPNG::Image.from_blob( data ) new( img, width: width, height: height ) end |
.sha256(data) ⇒ Object
7 8 9 10 |
# File 'lib/cryptopunks/composite.rb', line 7 def self.sha256( data ) ## todo/check: or just use Digest::SHA256.hexdigest - why? why not? Digest::SHA256.digest( data ).unpack( 'H*' )[0] end |