Class: RDL::Type::NonNullType
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #<=(other) ⇒ Object
-
#==(other) ⇒ Object
(also: #eql?)
:nodoc:.
-
#hash ⇒ Object
:nodoc:.
-
#initialize(type) ⇒ NonNullType
constructor
A new instance of NonNullType.
- #instantiate(inst) ⇒ Object
- #match(other) ⇒ Object
- #member?(obj, *args) ⇒ Boolean
- #to_s ⇒ Object
Methods inherited from Type
#canonical, leq, #nil_type?, #optional?, #to_contract, #vararg?
Constructor Details
#initialize(type) ⇒ NonNullType
Returns a new instance of NonNullType.
7 8 9 10 11 12 |
# File 'lib/rdl/types/non_null.rb', line 7 def initialize(type) @type = type raise RuntimeError, "Singleton types are always non-null" if type.is_a? SingletonType raise RuntimeError, "Attempt to create doubly non-null type" if type.is_a? NonNullType super() end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/rdl/types/non_null.rb', line 5 def type @type end |
Instance Method Details
#<=(other) ⇒ Object
37 38 39 |
# File 'lib/rdl/types/non_null.rb', line 37 def <=(other) return Type.leq(self, other) end |
#==(other) ⇒ Object Also known as: eql?
:nodoc:
18 19 20 21 22 |
# File 'lib/rdl/types/non_null.rb', line 18 def ==(other) # :nodoc: return false if other.nil? other = other.canonical return (other.instance_of? NonNullType) && (other.type == @type) end |
#hash ⇒ Object
:nodoc:
33 34 35 |
# File 'lib/rdl/types/non_null.rb', line 33 def hash # :nodoc: return 157 + @type.hash end |
#instantiate(inst) ⇒ Object
46 47 48 |
# File 'lib/rdl/types/non_null.rb', line 46 def instantiate(inst) return NonNullType.new(@type.instantiate(inst)) end |
#match(other) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/rdl/types/non_null.rb', line 26 def match(other) other = other.canonical other = other.type if other.instance_of? AnnotatedArgType return true if other.instance_of? WildQuery return (other.instance_of? NonNullType) && (@type.match(other.type)) end |
#member?(obj, *args) ⇒ Boolean
41 42 43 44 |
# File 'lib/rdl/types/non_null.rb', line 41 def member?(obj, *args) return false if obj.nil? @type.member?(obj, *args) end |
#to_s ⇒ Object
14 15 16 |
# File 'lib/rdl/types/non_null.rb', line 14 def to_s return "!#{@type.to_s}" end |