mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
0ed26f8352
Follow mruby's naming convention: non-static types, macros, and functions use the mrb_/MRB_ prefix. Renamed: - union mt_ptr -> union mrb_mt_ptr - mt_tbl -> mrb_mt_tbl - MT_KEY(), MT_FUNC, MT_NOARG, MT_PUBLIC, MT_PRIVATE -> MRB_MT_* - MT_KEY_SHIFT, MT_READONLY_BIT, MT_REMOVED_P -> MRB_MT_* - mt_init_rom() -> mrb_mt_init_rom() File-local static functions and macros in class.c are unchanged. Co-authored-by: Claude <noreply@anthropic.com>
mruby-symbol-ext
This gem extends mruby's Symbol class with additional useful methods.
Methods
Here are the methods added to the Symbol class:
capitalize
- call-seq:
sym.capitalize -> symbol - Returns a new symbol with the first character converted to uppercase and the remainder to lowercase. Equivalent to
sym.to_s.capitalize.intern.
downcase
- call-seq:
sym.downcase -> symbol - Returns a new symbol with all characters converted to lowercase. Equivalent to
sym.to_s.downcase.intern.
upcase
- call-seq:
sym.upcase -> symbol - Returns a new symbol with all characters converted to uppercase. Equivalent to
sym.to_s.upcase.intern.
casecmp(other_symbol)
- call-seq:
sym.casecmp(other) -> -1, 0, +1 or nil - Performs a case-insensitive comparison between two symbols. Returns -1, 0, or +1 if
other_symbolis a symbol. Returnsnilifother_symbolis not a symbol.
casecmp?(other_symbol)
- call-seq:
sym.casecmp?(other) -> true, false, or nil - Returns
trueif the receiver andother_symbolare equal after case folding,falseif they are not equal. Returnsnilifother_symbolis not a symbol.
empty?
- call-seq:
sym.empty? -> true or false - Returns
trueif the symbol's string representation is empty (i.e.,:""),falseotherwise.
length / size
- call-seq:
sym.length -> integersym.size -> integer
- Returns the length of the symbol's string representation.
sizeis an alias forlength.
Symbol.all_symbols (Conditional)
- call-seq:
Symbol.all_symbols => array - Returns an array of all symbols currently in mruby's symbol table.
- Note: This method is only available if mruby is compiled with the
MRB_USE_ALL_SYMBOLSdefine.