Top Level Namespace

Defined Under Namespace

Modules: Bool, ConversionFunctions, Sandbox, Solidity, Types Classes: ContractBase, FalseClass, TrueClass, ValueError

Constant Summary collapse

TypedString =
Types::String
TypedAddress =
Types::Address
TypedInscriptionId =
Types::InscriptionId
TypedBytes32 =
Types::Bytes32
TypedBytes =
Types::Bytes
TypedUInt =
Types::UInt
TypedInt =
Types::Int
TypedTimestamp =
Types::Timestamp
TypedTimedelta =
Types::Timedelta
TypedArray =
Types::Array
TypedMapping =
Types::Mapping
TypedEnum =
Types::Enum
TypedStruct =
Types::Struct
TypedEvent =
Types::Event
T =

make T an alias for Types - why? why not?

Types

Instance Method Summary collapse

Instance Method Details

#_sanitize_class_name(name) ⇒ Object

global helper(s) - move to ??? - why? why not?



18
19
20
21
22
23
24
25
26
27
# File 'lib/solidity/typed/metatypes/types.rb', line 18

def _sanitize_class_name( name )
  name = name.sub( /\bContractBase::/, '' )   ## remove contract module from name if present
  name = name.sub( /\bContract::/, '' )   ## remove contract module from name if present
  name = name.sub( /\bTyped::/, '' )
  name = name.sub( /\bTypes::/, '' )
  name = name.sub( /\bTypedArray::/, '' )
  name = name.sub( /\bTypedMapping::/, '' )
  name = name.gsub( '::', '' )                ## remove module separator if present
  name
end

say hello



128
# File 'lib/solidity/typed.rb', line 128

puts Solidity::Module::Typed.banner

#forwardableObject

def_delegate



3
# File 'lib/solidity/typed.rb', line 3

require 'forwardable'

#typeof(obj) ⇒ Object

(global) convenience helper to get type

use a different name 
   e.g. typedef( obj ) or
        typedclass_to_type( obj ) or
         Type( obj ) or type() ??

Raises:

  • (ArgumentError)


89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/solidity/typed.rb', line 89

def typeof( obj )
    ## case 1) already a metatype?
    return obj         if obj.is_a?( Types::Typed::Type )
    ## case 2a) check for (typed) class
    ##    check for Typed ancestor in class - why? why not?
    ##     e.g.    obj.ancestors.include?( Types::Typed )
    ##      2b)  Bool module
    return obj.type    if obj.instance_of?( Class ) && obj.respond_to?( :type ) 
    return obj.type    if obj == Bool   ## special case for module Bool!!!
  
##   support plain objects too here - why? why not?     
##   -- check for "plain objects"
##      return obj.class.type    if obj.class.respond_to?( :type )
    
   raise ArgumentError, "metatype or typedclass expected; got #{obj.inspect}"                                                                                 
end