struct

Rubellite::Value

Inherits Struct < Value < Object

Represents a first-class Ruby value (equivalent to Ruby's C VALUE). Provides transparent type checks, unboxing to Crystal primitives, dynamic method dispatch, operator overloads, and block execution.

Constructors

from(obj) : Value

Converts a Crystal object to a Rubellite::Value

Source
new(raw : LibRuby::Value)
Source

Instance methods

*(other) : Value
Source
+(other) : Value
Source
-(other) : Value
Source
/(other) : Value
Source
<(other) : Bool
Source
<=(other) : Bool
Source
==(other : Value) : Bool
Source
==(other) : Bool

Returns true if this struct is equal to other.

Both structs' instance vars are compared to each other. Thus, two structs are considered equal if each of their instance variables are equal. Subclasses should override this method to provide specific equality semantics.

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

p1 = Point.new 1, 2
p2 = Point.new 1, 2
p3 = Point.new 3, 4

p1 == p2 # => true
p1 == p3 # => false
Source
>(other) : Bool
Source
>=(other) : Bool
Source
[](key) : Value
Source
[]=(key, val) : Value
Source
array?
Source
as_crystal

Auto-converts to Crystal primitive where possible

Source
bool?
Source
call(method_name : String | Symbol, *args) : Value

Invokes a method on the Ruby object

Source
call_with_block(method_name : String | Symbol, *args, &block : Array(Value) -> Value) : Value

Invokes a method while passing a Crystal block as a Ruby block

Source
class_name
Source
false?
Source
fixnum?
Source
flonum?
Source
hash?
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
inspect

Returns an unambiguous and information-rich string representation of this object, typically intended for developers.

This method should usually not be overridden. It delegates to #inspect(IO) which can be overridden for custom implementations.

Also see #to_s.

Source
numeric?
Source
proc?
Source
ruby_nil?
Source
string?
Source
symbol?
Source
symbol_name
Source
to_a
Source
to_bool

Ruby truthiness: false and nil are falsey, everything else is truthy

Source
to_f
Source
to_f64
Source
to_h
Source
to_i
Source
to_i32
Source
to_i64
Source
to_s(io : IO) : Nil

Same as #inspect(io).

Source
to_s

Returns a nicely readable and concise string representation of this object, typically intended for users.

This method should usually not be overridden. It delegates to #to_s(IO) which can be overridden for custom implementations.

Also see #inspect.

Source
to_sym
Source
true?
Source