Class: Web3::Hpb::Block

Inherits:
Object
  • Object
show all
Includes:
Utility
Defined in:
lib/web3/hpb/block.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utility

#from_hex, #hex, #remove_0x_head, #wei_to_hpb

Constructor Details

#initialize(block_data) ⇒ Block

Returns a new instance of Block.



11
12
13
14
15
16
17
18
19
20
# File 'lib/web3/hpb/block.rb', line 11

def initialize(block_data)
  @raw_data =  block_data

  block_data.each do |k, v|
    self.instance_variable_set("@#{k}", v)
    self.class.send(:define_method, k, proc {self.instance_variable_get("@#{k}")})
  end

  @transactions = @transactions.collect { |t| Web3::Hpb::Transaction.new(t)}
end

Instance Attribute Details

#raw_dataObject (readonly)

Returns the value of attribute raw_data.



9
10
11
# File 'lib/web3/hpb/block.rb', line 9

def raw_data
  @raw_data
end

Instance Method Details

#block_numberObject



26
27
28
# File 'lib/web3/hpb/block.rb', line 26

def block_number
  from_hex(number)
end

#timestamp_timeObject



22
23
24
# File 'lib/web3/hpb/block.rb', line 22

def timestamp_time
  Time.at(from_hex timestamp )
end