Class: T::NilableType

Inherits:
Object
  • Object
show all
Defined in:
lib/emery/type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(inner_type) ⇒ NilableType

Returns a new instance of NilableType.



21
22
23
# File 'lib/emery/type.rb', line 21

def initialize(inner_type)
  @inner_type = inner_type
end

Instance Attribute Details

#inner_typeObject (readonly)

Returns the value of attribute inner_type.



20
21
22
# File 'lib/emery/type.rb', line 20

def inner_type
  @inner_type
end

Instance Method Details

#==(other) ⇒ Object



32
33
34
# File 'lib/emery/type.rb', line 32

def ==(other)
  T.instance_of?(NilableType, other) and self.inner_type == other.inner_type
end

#check(value) ⇒ Object



27
28
29
30
31
# File 'lib/emery/type.rb', line 27

def check(value)
  if value != nil
    T.check(inner_type, value)
  end
end

#to_sObject



24
25
26
# File 'lib/emery/type.rb', line 24

def to_s
  "Nilable[#{inner_type.to_s}]"
end