Class: Sheetah::Types::Scalars::Scalar

Inherits:
Type
  • Object
show all
Defined in:
lib/sheetah/types/scalars/scalar.rb

Instance Attribute Summary

Attributes inherited from Type

#cast_chain

Instance Method Summary collapse

Methods inherited from Type

all, cast, #cast, freeze, #freeze, #initialize, new!, #scalar?

Constructor Details

This class inherits a constructor from Sheetah::Types::Type

Instance Method Details

#composite(_value, _messenger) ⇒ Object

Raises:



17
18
19
# File 'lib/sheetah/types/scalars/scalar.rb', line 17

def composite(_value, _messenger)
  raise Errors::TypeError, "A scalar type cannot act as a composite"
end

#composite?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/sheetah/types/scalars/scalar.rb', line 13

def composite?
  false
end

#scalar(index, value, messenger) ⇒ Object

Raises:



21
22
23
24
25
# File 'lib/sheetah/types/scalars/scalar.rb', line 21

def scalar(index, value, messenger)
  raise Errors::TypeError, "A scalar type cannot be indexed" unless index.nil?

  cast_chain.call(value, messenger)
end