Class: Types::Typed::EventType

Inherits:
ReferenceType show all
Defined in:
lib/solidity/typed/metatypes/types.rb

Overview

event for now kind of like a struct - why? why not?

but MUST be initialized (and than frozen) 
and no zero possible etc.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Type

#array?, #check_and_normalize_literal, #eql?, #hash, #mapping?, #parse_integer, #pretty_print, #raise_type_error

Constructor Details

#initialize(event_name, event_class) ⇒ EventType

Returns a new instance of EventType.



403
404
405
406
# File 'lib/solidity/typed/metatypes/types.rb', line 403

def initialize( event_name, event_class )
  @event_name  = event_name
  @event_class = event_class
end

Instance Attribute Details

#event_classObject (readonly)

reference event_class here - why? why not?



402
403
404
# File 'lib/solidity/typed/metatypes/types.rb', line 402

def event_class
  @event_class
end

#event_nameObject (readonly)

Returns the value of attribute event_name.



401
402
403
# File 'lib/solidity/typed/metatypes/types.rb', line 401

def event_name
  @event_name
end

Instance Method Details

#==(other) ⇒ Object

check what abi looks like if possible for event

is like tuple?


417
418
419
420
421
# File 'lib/solidity/typed/metatypes/types.rb', line 417

def ==(other)
  other.is_a?( EventType ) &&
  @event_name  == other.event_name &&  ## check for name too - why? why not? 
  @event_class == other.event_class 
end

#formatObject Also known as: to_s



407
408
409
410
411
# File 'lib/solidity/typed/metatypes/types.rb', line 407

def format
  ## use tuple here (not event) - why? why not?
   named_types = @event_class.attributes.map  {|key,type| "#{key} #{type.format}" }
   "#{@event_name} event(#{named_types.join(',')})" 
end

#mut?Boolean

note: mut? == true MUST use new_zero (dup)

mut? == false MUST use zero (frozen/shared/singelton)

Returns:

  • (Boolean)


429
# File 'lib/solidity/typed/metatypes/types.rb', line 429

def mut?() false; end

#new(initial_values) ⇒ Object

todo/check: change to values with splat - why? why not?



435
436
437
438
439
# File 'lib/solidity/typed/metatypes/types.rb', line 435

def new( initial_values )  ## todo/check: change to values with splat - why? why not?  
    ## note: use "splat" here - must be empty or matching number of fields/attributes
    ##  change - why? why not?
   @event_class.new( *initial_values ) 
end

#typedclassObject



425
# File 'lib/solidity/typed/metatypes/types.rb', line 425

def typedclass() @event_class;  end

#typedclass_nameObject



424
# File 'lib/solidity/typed/metatypes/types.rb', line 424

def typedclass_name() @event_class.name;  end

#zeroObject Also known as: new_zero



430
431
432
# File 'lib/solidity/typed/metatypes/types.rb', line 430

def zero
  raise "event cannot be zero (by defintion); sorry"
end