Class: Gelauto::GenericType

Inherits:
Object
  • Object
show all
Defined in:
lib/gelauto/generic_type.rb

Direct Known Subclasses

ArrayType, HashType

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ruby_type, generic_arg_names = []) ⇒ GenericType

Returns a new instance of GenericType.



7
8
9
10
11
12
13
14
# File 'lib/gelauto/generic_type.rb', line 7

def initialize(ruby_type, generic_arg_names = [])
  @ruby_type = ruby_type
  @generic_args = {}

  generic_arg_names.each_with_object({}) do |generic_arg_name, ret|
    generic_args[generic_arg_name] = TypeSet.new
  end
end

Instance Attribute Details

#generic_argsObject (readonly)

Returns the value of attribute generic_args.



5
6
7
# File 'lib/gelauto/generic_type.rb', line 5

def generic_args
  @generic_args
end

#ruby_typeObject (readonly)

Returns the value of attribute ruby_type.



5
6
7
# File 'lib/gelauto/generic_type.rb', line 5

def ruby_type
  @ruby_type
end

Instance Method Details

#[](generic_arg_name) ⇒ Object



16
17
18
# File 'lib/gelauto/generic_type.rb', line 16

def [](generic_arg_name)
  generic_args[generic_arg_name]
end

#to_sigObject

Raises:

  • (NotImplementedError)


20
21
22
# File 'lib/gelauto/generic_type.rb', line 20

def to_sig
  raise NotImplementedError, "please define #{__method__} in derived classes"
end