pub struct RClass(/* private fields */);
Expand description
A Value pointer to a RClass struct, Ruby’s internal representation of classes.
See the Class
trait for methods available on classes.
See the Module
trait for defining instance methods and nested
classes/modules.
See the Object
trait for defining singlton methods (aka class methods).
See the ReprValue
trait for additional methods available on this type.
Implementations§
source§impl RClass
impl RClass
sourcepub fn from_value(val: Value) -> Option<Self>
pub fn from_value(val: Value) -> Option<Self>
Return Some(RClass)
if val
is a RClass
, None
otherwise.
§Examples
use magnus::{eval, RClass};
assert!(RClass::from_value(eval("String").unwrap()).is_some());
assert!(RClass::from_value(eval("Enumerable").unwrap()).is_none());
assert!(RClass::from_value(eval("nil").unwrap()).is_none());
Trait Implementations§
source§impl Class for RClass
impl Class for RClass
source§fn as_r_class(self) -> RClass
fn as_r_class(self) -> RClass
Return
self
as an RClass
.source§fn define_alloc_func<T>(self)
fn define_alloc_func<T>(self)
source§fn undef_default_alloc_func(self)
fn undef_default_alloc_func(self)
Remove the allocator function of a class if it is Ruby’s default
allocator function. Read more
source§impl Module for RClass
impl Module for RClass
source§fn define_class<T>(self, name: T, superclass: RClass) -> Result<RClass, Error>where
T: IntoId,
fn define_class<T>(self, name: T, superclass: RClass) -> Result<RClass, Error>where
T: IntoId,
Define a class in
self
’s scope. Read moresource§fn define_module<T>(self, name: T) -> Result<RModule, Error>where
T: IntoId,
fn define_module<T>(self, name: T) -> Result<RModule, Error>where
T: IntoId,
Define a module in
self
’s scope. Read moresource§fn define_error<T>(
self,
name: T,
superclass: ExceptionClass
) -> Result<ExceptionClass, Error>where
T: IntoId,
fn define_error<T>(
self,
name: T,
superclass: ExceptionClass
) -> Result<ExceptionClass, Error>where
T: IntoId,
Define an exception class in
self
’s scope. Read moresource§fn is_inherited<T>(self, other: T) -> bool
fn is_inherited<T>(self, other: T) -> bool
source§fn ancestors(self) -> RArray
fn ancestors(self) -> RArray
Return the classes and modules
self
inherits, includes, or prepends. Read moresource§fn define_method<T, M>(self, name: T, func: M) -> Result<(), Error>
fn define_method<T, M>(self, name: T, func: M) -> Result<(), Error>
Define a method in
self
’s scope. Read moresource§fn define_private_method<M>(self, name: &str, func: M) -> Result<(), Error>where
M: Method,
fn define_private_method<M>(self, name: &str, func: M) -> Result<(), Error>where
M: Method,
Define a private method in
self
’s scope. Read moresource§fn define_protected_method<M>(self, name: &str, func: M) -> Result<(), Error>where
M: Method,
fn define_protected_method<M>(self, name: &str, func: M) -> Result<(), Error>where
M: Method,
Define a protected method in
self
’s scope. Read moresource§impl Object for RClass
impl Object for RClass
source§fn define_singleton_method<M>(self, name: &str, func: M) -> Result<(), Error>where
M: Method,
fn define_singleton_method<M>(self, name: &str, func: M) -> Result<(), Error>where
M: Method,
Define a singleton method in
self
’s scope. Read moresource§impl ReprValue for RClass
impl ReprValue for RClass
source§fn equal<T>(self, other: T) -> Result<bool, Error>where
T: ReprValue,
fn equal<T>(self, other: T) -> Result<bool, Error>where
T: ReprValue,
Checks for equality, delegating to the Ruby method
#==
. Read moresource§fn eql<T>(self, other: T) -> Result<bool, Error>where
T: ReprValue,
fn eql<T>(self, other: T) -> Result<bool, Error>where
T: ReprValue,
Checks for equality, delegating to the Ruby method
#eql?
. Read moresource§fn hash(self) -> Result<Integer, Error>
fn hash(self) -> Result<Integer, Error>
Returns an integer non-uniquely identifying
self
. Read moresource§fn to_bool(self) -> bool
fn to_bool(self) -> bool
Convert
self
to a bool
, following Ruby’s rules of false
and nil
as boolean false
and everything else boolean true
. Read moresource§fn funcall_public<M, A, T>(self, method: M, args: A) -> Result<T, Error>
fn funcall_public<M, A, T>(self, method: M, args: A) -> Result<T, Error>
source§fn block_call<M, A, R, T>(
self,
method: M,
args: A,
block: fn(_: &[Value], _: Option<Proc>) -> R
) -> Result<T, Error>
fn block_call<M, A, R, T>( self, method: M, args: A, block: fn(_: &[Value], _: Option<Proc>) -> R ) -> Result<T, Error>
source§fn respond_to<M>(self, method: M, include_private: bool) -> Result<bool, Error>where
M: IntoId,
fn respond_to<M>(self, method: M, include_private: bool) -> Result<bool, Error>where
M: IntoId,
Check if
self
responds to the given Ruby method. Read moresource§fn is_kind_of<T>(self, class: T) -> bool
fn is_kind_of<T>(self, class: T) -> bool
source§fn enumeratorize<M, A>(self, method: M, args: A) -> Enumerator ⓘwhere
M: IntoSymbol,
A: ArgList,
fn enumeratorize<M, A>(self, method: M, args: A) -> Enumerator ⓘwhere
M: IntoSymbol,
A: ArgList,
source§impl TryConvert for RClass
impl TryConvert for RClass
impl Copy for RClass
Auto Trait Implementations§
impl Freeze for RClass
impl RefUnwindSafe for RClass
impl Send for RClass
impl Sync for RClass
impl Unpin for RClass
impl UnwindSafe for RClass
Blanket Implementations§
source§impl<T> AsRawValue for Twhere
T: ReprValue,
impl<T> AsRawValue for Twhere
T: ReprValue,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more