Class: Web3::Eth::Block

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utility

#from_hex, #hex, #remove_0x_head, #wei_to_ether

Constructor Details

#initialize(block_data) ⇒ Block

Returns a new instance of Block.



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

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::Eth::Transaction.new t }

end

Instance Attribute Details

#raw_dataObject (readonly)

Returns the value of attribute raw_data.



8
9
10
# File 'lib/web3ethereum/block.rb', line 8

def raw_data
  @raw_data
end

Instance Method Details

#block_numberObject



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

def block_number
  from_hex number
end

#timestamp_timeObject



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

def timestamp_time
  Time.at from_hex timestamp
end