Class: Vedeu::Coercers::Coercer Private

Inherits:
Object
  • Object
show all
Includes:
Vedeu::Common
Defined in:
lib/vedeu/coercers/coercer.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.

Provides the mechanism to convert a value into another value.

Direct Known Subclasses

Chars, Colour, EditorLine, EditorLines, Lines, Page, Position, Row, Streams, Style

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Vedeu::Common

#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?

Constructor Details

#initialize(value) ⇒ Vedeu::Coercers::Coercer

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.

Returns a new instance of the Vedeu::Coercers::Coercer subclass.

Parameters:

  • value (void)


26
27
28
# File 'lib/vedeu/coercers/coercer.rb', line 26

def initialize(value)
  @value = value
end

Instance Attribute Details

#valuevoid (readonly, protected)

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.

This method returns an undefined value.



39
40
41
# File 'lib/vedeu/coercers/coercer.rb', line 39

def value
  @value
end

Class Method Details

.coerce(value) ⇒ Object

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.

Parameters:

  • value (void)


17
18
19
# File 'lib/vedeu/coercers/coercer.rb', line 17

def self.coerce(value)
  new(value).coerce
end

Instance Method Details

#coerceObject

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.

Raises:

  • (Vedeu::Error::NotImplemented)

    When a subclass of the current class actually implements the method. Usually an indicator that the subclass should be used instead of the current class.



31
32
33
# File 'lib/vedeu/coercers/coercer.rb', line 31

def coerce
  raise Vedeu::Error::NotImplemented, 'Subclasses implement this.'
end

#coerced?Boolean (private)

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.

Returns:



44
45
46
# File 'lib/vedeu/coercers/coercer.rb', line 44

def coerced?
  value.is_a?(klass)
end

#incoercible!Object (private)

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.

Raises:

  • (Vedeu::Error::Fatal)

    When Vedeu does not understand that which the client application is attempting to achieve.



49
50
51
52
# File 'lib/vedeu/coercers/coercer.rb', line 49

def incoercible!
  raise Vedeu::Error::Fatal,
        "Vedeu cannot coerce a '#{value.class.name}' into a '#{klass}'."
end

#klassObject (private)

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.

Raises:

  • (Vedeu::Error::NotImplemented)

    When a subclass of the current class actually implements the method. Usually an indicator that the subclass should be used instead of the current class.



55
56
57
# File 'lib/vedeu/coercers/coercer.rb', line 55

def klass
  raise Vedeu::Error::NotImplemented, 'Subclasses implement this.'
end