Method: Vedeu::Coercers::Position#coerce

Defined in:
lib/vedeu/coercers/position.rb

#coerceNilClass|Vedeu::Geometries::Position

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:

Raises:

  • (Vedeu::Error::Fatal)

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



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vedeu/coercers/position.rb', line 16

def coerce
  if value.nil? || coerced?
    value

  elsif tuple?
    klass.new(*value)

  elsif hash?(value)
    klass.new(value.fetch(:y, 1), value.fetch(:x, 1))

  elsif numeric?(value)
    klass.new(value, 1)

  else
    incoercible!

  end
end