abstract class Ven::Suite::MClass

Overview

The parent of all Models that are represented by a Crystal class; often Models that have no particular value.

Direct Known Subclasses

Defined in:

ven/suite/model.cr

Instance Method Summary

Instance Method Detail

def []=(referent : Model, value : Model) : Model | Nil #

Sets this model's referent item (whatever the meaning of that is) to value.

Models may choose to override this method.

Returns nil if found no referent item (this is the default meaning; it may be changed by the overriding model).


[View source]
def []?(index : Int) #

Returns index-th item of this model.

Subclasses should rather override this method instead of #nth.


[View source]
def []?(index : Range) #

Returns a subset of items in this model.

Subclasses should rather override this method instead of #nth.


[View source]
def callable? : Bool #

Returns whether this model is callable.


[View source]
def eqv?(other : Model) : Bool #

Returns whether this model is equal-by-value to the other model.


[View source]
def false? : Bool #

Returns whether this model is a false MBool. Note that it is likely not the inverse of #true?.


[View source]
def field(name : String) : Model | Nil #

Returns a field's value for this model, or nil if this model has no such field.


[View source]
def indexable? #

Returns whether this model is indexable (i.e., properly implements #nth).


[View source]
def length : Int32 #

Returns the length (#) of this model.


[View source]
def match(other : Model) #

Returns whether this model is of the type other, or is equal-by-value to other.


[View source]
def nth(index : Num) #

Returns the index-th item of this model,

Subclasses should not generally override this method. They should override #[]? instead.

Raises ModelCastException if index is improper.


[View source]
def nth(range : MRange) #

Returns a subset of items in this model.

Subclasses should not generally override this method. They should override #[]? instead.

Raises ModelCastException if index is improper.


[View source]
def nth(other) #

Returns a subset of items in this model.

Subclasses should not generally override this method. They should override #[]? instead.

Raises ModelCastException if index is improper.


[View source]
def of?(other : MType) : Bool #

Returns whether this model is of the type other.


[View source]
def of?(other : MAny) #

Returns whether this model is of the type other.


[View source]
def of?(other) #

Returns whether this model is of the type other.


[View source]
def set_referent(referent : Model, value : Model) : Model #

Sets this model's referent item (whatever the meaning of that is) to value.

Generally, subclasses should not choose to override this method. They can override #[]= instead.


[View source]
def to_bool(inverse = false) : MBool #

Converts (casts) this model into an MBool. Inverts this MBool (applies not) if inverse is true.


[View source]
def to_num : Num #

Converts (casts) this model into a Num.


[View source]
def to_str : Str #

Converts (casts) this model into a Str.


[View source]
def to_vec : Vec #

Converts (casts) this model into a Vec.


[View source]
def true? : Bool #

Returns whether this model is semantically true.


[View source]
def weight : MWeight #

Returns the weight (see MWeight) of this model.


[View source]