Class: Lapidar::Block

Inherits:
Object
  • Object
show all
Defined in:
lib/lapidar/block.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number:, hash:, nonce:, data: nil, created_at: Time.now.to_f) ⇒ Block

Returns a new instance of Block.



5
6
7
8
9
10
11
# File 'lib/lapidar/block.rb', line 5

def initialize(number:, hash:, nonce:, data: nil, created_at: Time.now.to_f)
  @number = number
  @hash = hash
  @nonce = nonce
  @data = data
  @created_at = created_at
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



3
4
5
# File 'lib/lapidar/block.rb', line 3

def created_at
  @created_at
end

#dataObject (readonly)

Returns the value of attribute data.



3
4
5
# File 'lib/lapidar/block.rb', line 3

def data
  @data
end

#hashObject (readonly)

Returns the value of attribute hash.



3
4
5
# File 'lib/lapidar/block.rb', line 3

def hash
  @hash
end

#nonceObject (readonly)

Returns the value of attribute nonce.



3
4
5
# File 'lib/lapidar/block.rb', line 3

def nonce
  @nonce
end

#numberObject (readonly)

Returns the value of attribute number.



3
4
5
# File 'lib/lapidar/block.rb', line 3

def number
  @number
end

Instance Method Details

#==(other) ⇒ Object



23
24
25
# File 'lib/lapidar/block.rb', line 23

def ==(other)
  to_h == other.to_h
end

#to_hObject



13
14
15
16
17
18
19
20
21
# File 'lib/lapidar/block.rb', line 13

def to_h
  {
    number: @number,
    hash: @hash,
    nonce: @nonce,
    data: @data,
    created_at: @created_at,
  }
end