module Popcorn::Cast

Defined in:

popcorn/cast.cr

Instance Method Summary

Instance Method Detail

def raise_error!(source : String, target : String) #

[View source]
def to_bool(v : T) forall T #

Returns the Bool value represented by given data type.


[View source]
def to_bool?(v : T) forall T #

Returns the Bool or Nil value represented by given data type. It accepts true, t, yes, y, on, 1, false, f, no, n, off, 0. Any other value return an error.


[View source]
def to_float(v : T) forall T #

Returns the Float value represented by given data type.


[View source]
def to_float32(v : T) forall T #

Returns the Float32 value represented by given data type.


[View source]
def to_float32?(v : T) forall T #

Returns the Float32 or Nil value represented by given data type.


[View source]
def to_float64(v : T) forall T #

Returns the Float64 value represented by given data type.


[View source]
def to_float64?(v : T) forall T #

Alias to #to_float64?


[View source]
def to_float?(v : T) forall T #

Returns the Float64 or Nil value represented by given data type.


[View source]
def to_int(v : T) forall T #

Returns the Int value represented by given data type.


[View source]
def to_int16(v : T) forall T #

Returns the Int16 value represented by given data type.


[View source]
def to_int16?(v : T) forall T #

Returns the Int16 or Nil value represented by given data type.


[View source]
def to_int32(v : T) forall T #

Returns the Int32 value represented by given data type.


[View source]
def to_int32?(v : T) forall T #

Alias to #to_int?


[View source]
def to_int64(v : T) forall T #

Returns the Int64 value represented by given data type.


[View source]
def to_int64?(v : T) forall T #

Returns the Int64 or Nil value represented by given data type.


[View source]
def to_int8(v : T) forall T #

Returns the Int8 value represented by given data type.


[View source]
def to_int8?(v : T) forall T #

Returns the Int8 or Nil value represented by given data type.


[View source]
def to_int?(v : T) forall T #

Returns the Int32 or Nil value represented by given data type.


[View source]
def to_time(v : T, location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil) forall T #

Returns the Time value represented by given data type.


[View source]
def to_time?(v : T, location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil) forall T #

Returns the Time or Nil value represented by given data type.

  • location argument applies for Int/String types
  • formatters argument applies for String type.

[View source]
def to_uint(v : T) forall T #

Returns the UInt value represented by given data type.


[View source]
def to_uint16(v : T) forall T #

Returns the UInt16 value represented by given data type.


[View source]
def to_uint16?(v : T) forall T #

Returns the UInt16 or Nil value represented by given data type.


[View source]
def to_uint32(v : T) forall T #

Returns the UInt32 value represented by given data type.


[View source]
def to_uint32?(v : T) forall T #

Alias to #to_uint?


[View source]
def to_uint64(v : T) forall T #

Returns the UInt64 value represented by given data type.


[View source]
def to_uint64?(v : T) forall T #

Returns the UInt64 or Nil value represented by given data type.


[View source]
def to_uint8(v : T) forall T #

Returns the UInt8 value represented by given data type.


[View source]
def to_uint8?(v : T) forall T #

Returns the Int8 or Nil value represented by given data type.


[View source]
def to_uint?(v : T) forall T #

Returns the UInt32 or Nil value represented by given data type.


[View source]