Class: Types::Typed::BoolType

Inherits:
DataType show all
Defined in:
lib/solidity/typed/metatypes/bool.rb

Class Method 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

Class Method Details

.instanceObject



6
# File 'lib/solidity/typed/metatypes/bool.rb', line 6

def self.instance() @instance ||= new; end

Instance Method Details

#==(other) ⇒ Object



11
# File 'lib/solidity/typed/metatypes/bool.rb', line 11

def ==(other)  other.is_a?( BoolType ); end

#formatObject Also known as: to_s



8
# File 'lib/solidity/typed/metatypes/bool.rb', line 8

def format() 'bool'; end

#mut?Boolean

Returns:

  • (Boolean)


20
# File 'lib/solidity/typed/metatypes/bool.rb', line 20

def mut?() false; end

#new(initial_value) ⇒ Object

check - add default zero value - why? why not?



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/solidity/typed/metatypes/bool.rb', line 23

def new( initial_value )   ## check - add default zero value - why? why not?
   ## allow integer 0|1 here too - why? why not?
   ##  fix-fix-fix  check solidity functions with bool (if they use 0|1 or true|false)!!!
   if initial_value == true    # instance_of( TrueClass )
      true
   elsif initial_value == false  # instance_of?( FalseClass )
      false
   else
      ## use value error?
      raise ArgumentError, "BoolType.new - true or false arg expected; got: #{initial_value}"
   end
end

#typedclassObject



18
# File 'lib/solidity/typed/metatypes/bool.rb', line 18

def typedclass()       Bool;  end

#typedclass_nameObject

note: class is really a module for bool - hack!!!

 remove class from methods (typedclass_name|typedclass) - why? why not?
change typedclass_name to typed_name !!!
 and   typedclass      to typed      !!! - why? why not??


17
# File 'lib/solidity/typed/metatypes/bool.rb', line 17

def typedclass_name()  Bool.name; end

#zeroObject Also known as: new_zero

note: Bool.zero is false



21
# File 'lib/solidity/typed/metatypes/bool.rb', line 21

def zero() Bool.zero; end