struct

Liquid::Any

Inherits Struct / Value / Object

Constructors

new(raw : Type)

Creates an instance of Liquid::Any that wraps the given value.

Source
new

Creates an instance of Liquid::Any with a value of nil.

Source

Instance methods

-

Assumes the underlying value is a numerical value, and returns the value with the opposite sign.

Source
<(other : Any) : Bool
Source
<<(value : Type) : Array(Any)

Assumes the underlying value is an Array and adds value to the array.

Source
<<(value : Any) : Array(Any)

Assumes the underlying value is an Array and adds value to the array.

Source
<=(other : Any) : Bool
Source
==(other : Any)

Returns true if both self and other's raw object are equal.

Source
==(other)

Returns true if the raw object is equal to other.

Source
>(other : Any) : Bool
Source
>=(other : Any) : Bool
Source
[](index : Int) : Any

Assumes the underlying value is an Array and returns the element at the given index. Raises if the underlying value is not an Array.

Source
[](key : String) : Any

Assumes the underlying value is a Hash and returns the element with the given key. Raises if the underlying value is not a Hash.

Source
[]=(key : String | Symbol, value : Type) : Type

Assumes the underlying value is a Hashand assigns a value at the given key. Raises if the underlying value is not a Hash.

Source
[]=(key : String | Symbol, value : Any) : Any

Assumes the underlying value is a Hashand assigns a value at the given key. Raises if the underlying value is not a Hash.

Source
[]?(index : Int) : Any | Nil

Assumes the underlying value is an Array and returns the element at the given index, or nil if out of bounds. Raises if the underlying value is not an Array.

Source
[]?(key : String) : Any | Nil

Assumes the underlying value is a Hash and returns the element with the given key, or nil if the key is not present. Raises if the underlying value is not a Hash.

Source
as_a

Checks that the underlying value is Array, and returns its value. Raises otherwise.

Source
as_a?

Checks that the underlying value is Array, and returns its value. Returns nil otherwise.

Source
as_bool

Checks that the underlying value is Bool, and returns its value. Raises otherwise.

Source
as_bool?

Checks that the underlying value is Bool, and returns its value. Returns nil otherwise.

Source
as_f

Checks that the underlying value is Float, and returns its value as an Float64. Raises otherwise.

Source
as_f32

Checks that the underlying value is Float, and returns its value as an Float32. Raises otherwise.

Source
as_f32?

Checks that the underlying value is Float, and returns its value as an Float32. Returns nil otherwise.

Source
as_f?

Checks that the underlying value is Float, and returns its value as an Float64. Returns nil otherwise.

Source
as_h

Checks that the underlying value is Hash, and returns its value. Raises otherwise.

Source
as_h?

Checks that the underlying value is Hash, and returns its value. Returns nil otherwise.

Source
as_i

Checks that the underlying value is Int, and returns its value as an Int32. Raises otherwise.

Source
as_i64

Checks that the underlying value is Int, and returns its value as an Int64. Raises otherwise.

Source
as_i64?

Checks that the underlying value is Int, and returns its value as an Int64. Returns nil otherwise.

Source
as_i?

Checks that the underlying value is Int, and returns its value as an Int32. Returns nil otherwise.

Source
as_nil

Checks that the underlying value is Nil, and returns nil. Raises otherwise.

Source
as_number

Checks that the underlying value is a Number, and returns its value. Raises otherwise.

Source
as_number?

Checks that the underlying value is a Number, and returns its value. Returns nil otherwise.

Source
as_number_or_zero

Checks that the underlying value is a Number, and returns its value. Returns 0 otherwise.

Source
as_s

Checks that the underlying value is String, and returns its value. Raises otherwise.

Source
as_s?

Checks that the underlying value is String, and returns its value. Returns nil otherwise.

Source
as_t

Checks that the underlying value is Time, and returns its value. Raises otherwise.

Source
as_t?

Checks that the underlying value is Time, and returns its value. Returns nil otherwise.

Source
contains?(other : Any) : Bool

Returns true if the underlying value is an Array or String, and contains other, false otherwise.

Source
dig(index_or_key : String | Int, *subkeys) : Any

Traverses the depth of a structure and returns the value, otherwise raises.

Source
dig?(index_or_key : String | Int, *subkeys) : Any | Nil

Traverses the depth of a structure and returns the value. Returns nil if not found.

Source
hash(hasher)

See Object#hash(hasher)

Source
inspect(io : IO) : Nil

Appends this struct's name and instance variables names and values to the given IO.

struct Point
  def initialize(@x : Int32, @y : Int32)
  end
end

p1 = Point.new 1, 2
p1.to_s    # "Point(@x=1, @y=2)"
p1.inspect # "Point(@x=1, @y=2)"
Source
logical_and(other : Any) : Bool
Source
logical_or(other : Any) : Bool
Source
raw

Returns the raw underlying value.

Source
size

Assumes the underlying value is an Array or Hash and returns its size. Raises if the underlying value is not an Array or Hash.

Source
to_s(io : IO) : Nil

Returns a string representation of the underlying value.

Source

Nested types