method
to_s
v2_1_10 -
Show latest stable
- Class:
Module
to_s()public
Returns a string representing this module or class. For basic classes and modules, this is the name. For singletons, we show information on the thing we’re attached to as well.
static VALUE
rb_mod_to_s(VALUE klass)
{
ID id_defined_at;
VALUE refined_class, defined_at;
if (FL_TEST(klass, FL_SINGLETON)) {
VALUE s = rb_usascii_str_new2("#<Class:");
VALUE v = rb_ivar_get(klass, id__attached__);
if (CLASS_OR_MODULE_P(v)) {
rb_str_append(s, rb_inspect(v));
}
else {
rb_str_append(s, rb_any_to_s(v));
}
rb_str_cat2(s, ">");
return s;
}
refined_class = rb_refinement_module_get_refined_class(klass);
if (!NIL_P(refined_class)) {
VALUE s = rb_usascii_str_new2("#<refinement:");
rb_str_concat(s, rb_inspect(refined_class));
rb_str_cat2(s, "@");
CONST_ID(id_defined_at, "__defined_at__");
defined_at = rb_attr_get(klass, id_defined_at);
rb_str_concat(s, rb_inspect(defined_at));
rb_str_cat2(s, ">");
return s;
}
return rb_str_dup(rb_class_name(klass));
} Related methods
- Instance methods
- <
- <=
- <=>
- ==
- ===
- >
- >=
- ancestors
- autoload
- autoload?
- class_eval
- class_exec
- class_variable_defined?
- class_variable_get
- class_variable_set
- class_variables
- const_defined?
- const_get
- const_missing
- const_set
- constants
- freeze
- include
- include?
- included_modules
- infect_an_assertion
- infect_with_assertions
- initialize_copy
- inspect
- instance_method
- instance_methods
- method_defined?
- module_eval
- module_exec
- name
- prepend
- private_class_method
- private_constant
- private_instance_methods
- private_method_defined?
- protected_instance_methods
- protected_method_defined?
- psych_yaml_as
- public_class_method
- public_constant
- public_instance_method
- public_instance_methods
- public_method_defined?
- rake_extension
- remove_class_variable
- singleton_class?
- to_s
- yaml_as
- Class methods
- constants
- nesting
- new
- Private methods
-
alias_method -
append_features -
attr -
attr_accessor -
attr_reader -
attr_writer -
define_method -
extend_object -
extended -
included -
method_added -
method_removed -
method_undefined -
module_function -
prepend_features -
prepended -
private -
protected -
public -
refine -
remove_const -
remove_method -
undef_method -
using