Class: Carbon::Concrete::Item::Trait::Expectation Private

Inherits:
Object
  • Object
show all
Defined in:
lib/carbon/concrete/item/trait/expectation.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Note:

This class is frozen upon initialization. This means that any attempt to modify it will result in an error. In most cases, the attributes on this class will also be frozen, as well.

An expectation of a trait. This is a function that an implementing data type must implement to be considered a part of the trait.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, parameters, ret) ⇒ Expectation

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize the expectation with the given arguments.

Parameters:

  • name (::String)

    The name of the function for the expectation.

  • parameters (<Type>)

    The parameters of the function for the expectation.

  • ret (Type)

    The return type of the function for the expectation.

See Also:



45
46
47
48
49
50
# File 'lib/carbon/concrete/item/trait/expectation.rb', line 45

def initialize(name, parameters, ret)
  @name = name
  @parameters = parameters
  @return = ret
  deep_freeze!
end

Instance Attribute Details

#name::String (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The name of the function for this expectation. This is a string, and can be any valid function name for a carbon function.

Returns:

  • (::String)

    The function name.



21
22
23
# File 'lib/carbon/concrete/item/trait/expectation.rb', line 21

def name
  @name
end

#parameters<Type> (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The parameters of the function for this expectation. This is an array of types, which can contain generic parameters.

Returns:

  • (<Type>)

    The parameter types.



27
28
29
# File 'lib/carbon/concrete/item/trait/expectation.rb', line 27

def parameters
  @parameters
end

#returnType (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The return type of the function for this expectation. This is a single type, which can contain generic parameters.

Returns:

  • (Type)

    The return type.



33
34
35
# File 'lib/carbon/concrete/item/trait/expectation.rb', line 33

def return
  @return
end