Class: Ethereum::Function

Inherits:
Object
  • Object
show all
Defined in:
lib/ethereum/function.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Function

Returns a new instance of Function.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/ethereum/function.rb', line 6

def initialize(data)
  @name = data["name"]
  @constant = data["constant"]
  @inputs = data["inputs"].collect do |input|
    Ethereum::FunctionInput.new(input)
  end
  @outputs = data["outputs"].collect do |output|
    Ethereum::FunctionOutput.new(output)
  end
  @function_string = "#{@name}(#{@inputs.collect {|x| x.type }.join(",")})"
  @signature = Digest::SHA3.hexdigest(@function_string, 256)[0..7]
end

Instance Attribute Details

#constantObject

Returns the value of attribute constant.



4
5
6
# File 'lib/ethereum/function.rb', line 4

def constant
  @constant
end

#function_stringObject

Returns the value of attribute function_string.



4
5
6
# File 'lib/ethereum/function.rb', line 4

def function_string
  @function_string
end

#inputsObject

Returns the value of attribute inputs.



4
5
6
# File 'lib/ethereum/function.rb', line 4

def inputs
  @inputs
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/ethereum/function.rb', line 4

def name
  @name
end

#outputsObject

Returns the value of attribute outputs.



4
5
6
# File 'lib/ethereum/function.rb', line 4

def outputs
  @outputs
end

#signatureObject

Returns the value of attribute signature.



4
5
6
# File 'lib/ethereum/function.rb', line 4

def signature
  @signature
end