Class: RDL::Type::AnnotatedArgType
- Defined in:
- lib/rdl/types/annotated_arg.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
:nodoc:.
-
#hash ⇒ Object
doesn’t have a match method - queries shouldn’t have annotations in them.
-
#initialize(name, type) ⇒ AnnotatedArgType
constructor
Note: Named argument types aren’t hashconsed.
- #instantiate(inst) ⇒ Object
- #member?(obj, *args) ⇒ Boolean
- #optional? ⇒ Boolean
- #to_s ⇒ Object
- #vararg? ⇒ Boolean
Methods inherited from Type
#canonical, leq, #nil_type?, #to_contract
Constructor Details
#initialize(name, type) ⇒ AnnotatedArgType
Note: Named argument types aren’t hashconsed.
10 11 12 13 14 15 16 |
# File 'lib/rdl/types/annotated_arg.rb', line 10 def initialize(name, type) @name = name @type = type raise RuntimeError, "Attempt to create annotated type with non-type" unless type.is_a? Type raise RuntimeError, "Attempt to create doubly annotated type" if type.is_a? AnnotatedArgType super() end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/rdl/types/annotated_arg.rb', line 5 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/rdl/types/annotated_arg.rb', line 6 def type @type end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
:nodoc:
22 23 24 25 26 |
# File 'lib/rdl/types/annotated_arg.rb', line 22 def ==(other) # :nodoc: return false if other.nil? other = other.canonical return (other.instance_of? AnnotatedArgType) && (other.name == @name) && (other.type == @type) end |
#hash ⇒ Object
doesn’t have a match method - queries shouldn’t have annotations in them
32 33 34 |
# File 'lib/rdl/types/annotated_arg.rb', line 32 def hash # :nodoc: return (57 + @name.hash) * @type.hash end |
#instantiate(inst) ⇒ Object
40 41 42 |
# File 'lib/rdl/types/annotated_arg.rb', line 40 def instantiate(inst) return AnnotatedArgType.new(@name, @type.instantiate(inst)) end |
#member?(obj, *args) ⇒ Boolean
36 37 38 |
# File 'lib/rdl/types/annotated_arg.rb', line 36 def member?(obj, *args) @type.member?(obj, *args) end |
#optional? ⇒ Boolean
44 45 46 |
# File 'lib/rdl/types/annotated_arg.rb', line 44 def optional? return type.optional? end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/rdl/types/annotated_arg.rb', line 18 def to_s return "#{@type.to_s} #{@name}" end |
#vararg? ⇒ Boolean
48 49 50 |
# File 'lib/rdl/types/annotated_arg.rb', line 48 def vararg? return type.vararg? end |