Documentation
¶
Overview ¶
Package rgo 提供了一个类似 Ruby 的数组实现
Package rgo 提供了一个类似 Ruby 的哈希表实现 ¶
Package rgo 提供了一个类似 Ruby 的整数实现 ¶
Package rgo 提供了一个类似 Ruby 的字符串实现
Index ¶
- Constants
- type BaseObject
- type Method
- type MethodFunc
- type Object
- type RArray
- func (a RArray) All(fn func(Object) bool) bool
- func (a RArray) Any(fn func(Object) bool) bool
- func (a RArray) Compact() RArray
- func (a RArray) Count(obj Object) int
- func (a RArray) Drop(n int) RArray
- func (a RArray) Each(fn func(Object))
- func (a RArray) EachCons(n int, fn func(RArray))
- func (a RArray) EachSlice(n int, fn func(RArray))
- func (a RArray) EachWithIndex(fn func(Object, int))
- func (a RArray) Empty() bool
- func (a RArray) Equal(other Object) bool
- func (a RArray) First() Object
- func (a RArray) Flatten() RArray
- func (a RArray) Get(index int) Object
- func (a RArray) GroupBy(fn func(Object) Object) map[string]RArray
- func (a RArray) Include(obj Object) bool
- func (a RArray) Index(obj Object) int
- func (a RArray) Join(sep string) RString
- func (a RArray) Last() Object
- func (a RArray) Length() int
- func (a RArray) Map(fn func(Object) Object) RArray
- func (a RArray) None(fn func(Object) bool) bool
- func (a RArray) Partition(fn func(Object) bool) (RArray, RArray)
- func (a *RArray) Pop() Object
- func (a *RArray) Push(obj Object) *RArray
- func (a RArray) RIndex(obj Object) int
- func (a RArray) Reject(fn func(Object) bool) RArray
- func (a RArray) Reverse() RArray
- func (a RArray) Select(fn func(Object) bool) RArray
- func (a RArray) Shuffle() RArray
- func (a RArray) Size() int
- func (a RArray) Slice(start, end int) RArray
- func (a RArray) SliceFrom(start int) RArray
- func (a RArray) Sort() RArray
- func (a RArray) Take(n int) RArray
- func (a RArray) ToArray() []Object
- func (a RArray) ToString() string
- func (a RArray) Uniq() RArray
- type RClass
- func (c *RClass) After(methodName string, hook func(result any, args ...any)) *RClass
- func (c *RClass) Alias(newName, oldName string) *RClass
- func (c *RClass) AttrAccessor(names ...string) *RClass
- func (c *RClass) AttrReader(names ...string) *RClass
- func (c *RClass) AttrWriter(names ...string) *RClass
- func (c *RClass) Before(methodName string, hook func(args ...any)) *RClass
- func (c *RClass) Call(methodName string, args ...any) any
- func (c *RClass) ClassMethods() []string
- func (c *RClass) ClassVars() []string
- func (c *RClass) DefineClassMethod(name string, fn any) *RClass
- func (c *RClass) DefineEigenMethod(name string, fn any) *RClass
- func (c *RClass) DefineMethod(name string, fn any) *RClass
- func (c *RClass) EigenClass() *RClass
- func (c *RClass) EnablePooling() *RClass
- func (c *RClass) FastCall(methodName string, args ...any) any
- func (c *RClass) GetClassVar(name string) any
- func (c *RClass) GetInstanceVar(name string) any
- func (c *RClass) GetMethodDirectly(methodName string) *Method
- func (c *RClass) Inherit(parent *RClass) *RClass
- func (c *RClass) InstanceVars() []string
- func (c *RClass) IsA(className string) bool
- func (c *RClass) MethodMissing(handler func(name string, args ...any) any) *RClass
- func (c *RClass) Methods() []string
- func (c *RClass) Name() string
- func (c *RClass) New() *RClass
- func (c *RClass) Parent() *RClass
- func (c *RClass) RespondTo(methodName string) bool
- func (c *RClass) ReturnToPool()
- func (c *RClass) SetClassVar(name string, value any)
- func (c *RClass) SetInstanceVar(name string, value any)
- func (c *RClass) Super(methodName string, args ...any) any
- type RHash
- func (h *RHash) Clear()
- func (h *RHash) CompareByIdentity()
- func (h *RHash) CompareByIdentityQ() bool
- func (h *RHash) Default() any
- func (h *RHash) DefaultProc() any
- func (h *RHash) Delete(key any) any
- func (h *RHash) Each(fn func(key, value any))
- func (h *RHash) Equal(other Object) bool
- func (h *RHash) Fetch(key any, defaultValue ...any) (any, error)
- func (h *RHash) Get(key any) (any, bool)
- func (h *RHash) HasKey(key any) bool
- func (h *RHash) HasValue(value any) bool
- func (h *RHash) Inspect() string
- func (h *RHash) Keys() []any
- func (h *RHash) Merge(other *RHash) *RHash
- func (h *RHash) MergeBang(other *RHash)
- func (h *RHash) Reject(fn func(key, value any) bool) *RHash
- func (h *RHash) Select(fn func(key, value any) bool) *RHash
- func (h *RHash) Set(key, value any)
- func (h *RHash) Size() int
- func (h *RHash) ToA() RArray
- func (h *RHash) ToCSV() RString
- func (h *RHash) ToH() *RHash
- func (h *RHash) ToHTML() RString
- func (h *RHash) ToJSON() RString
- func (h *RHash) ToProc() any
- func (h *RHash) ToS() RString
- func (h *RHash) ToString() string
- func (h *RHash) ToTSV() RString
- func (h *RHash) ToXML() RString
- func (h *RHash) ToYAML() RString
- func (h *RHash) TransformKeys(fn func(key any) any) *RHash
- func (h *RHash) TransformValues(fn func(value any) any) *RHash
- func (h *RHash) Values() []any
- type RInteger
- func (i RInteger) Abs() RInteger
- func (i RInteger) Add(other int) RInteger
- func (i RInteger) AddRInt(other RInteger) RInteger
- func (i RInteger) AllBits(mask RInteger) bool
- func (i RInteger) AnyBits(mask RInteger) bool
- func (i RInteger) BitAnd(other RInteger) RInteger
- func (i RInteger) BitAt(pos RInteger) RInteger
- func (i RInteger) BitLength() int
- func (i RInteger) BitNot() RInteger
- func (i RInteger) BitOr(other RInteger) RInteger
- func (i RInteger) BitXor(other RInteger) RInteger
- func (i RInteger) Ceil() RInteger
- func (i RInteger) CeilDiv(other RInteger) RInteger
- func (i RInteger) CeilWithPrecision(digits RInteger) RInteger
- func (i RInteger) Chr() RString
- func (i RInteger) Coerce(other Object) RArray
- func (i RInteger) Digits(base ...int) RArray
- func (i RInteger) Div(other int) RInteger
- func (i RInteger) DivMod(other RInteger) RArray
- func (i RInteger) DivRInt(other RInteger) RInteger
- func (i RInteger) DownTo(limit RInteger, fn func(RInteger))
- func (i RInteger) Equal(other Object) bool
- func (i RInteger) Even() bool
- func (i RInteger) FDiv(other RInteger) float64
- func (i RInteger) Floor() RInteger
- func (i RInteger) FloorWithPrecision(digits RInteger) RInteger
- func (i RInteger) Gcd(other RInteger) RInteger
- func (i RInteger) GcdLcm(other RInteger) RArray
- func (i RInteger) Lcm(other RInteger) RInteger
- func (i RInteger) LeftShift(count RInteger) RInteger
- func (i RInteger) Mod(other int) RInteger
- func (i RInteger) ModRInt(other RInteger) RInteger
- func (i RInteger) Modulo(other int) RInteger
- func (i RInteger) ModuloRInt(other RInteger) RInteger
- func (i RInteger) Mul(other int) RInteger
- func (i RInteger) MulRInt(other RInteger) RInteger
- func (i RInteger) Negative() bool
- func (i RInteger) Next() RInteger
- func (i RInteger) NoBits(mask RInteger) bool
- func (i RInteger) Odd() bool
- func (i RInteger) Ord() RInteger
- func (i RInteger) Positive() bool
- func (i RInteger) Pow(exponent int) RInteger
- func (i RInteger) PowRInt(exponent RInteger) RInteger
- func (i RInteger) Pred() RInteger
- func (i RInteger) RightShift(count RInteger) RInteger
- func (i RInteger) Round() RInteger
- func (i RInteger) RoundWithPrecision(digits RInteger) RInteger
- func (i RInteger) Size() int
- func (i RInteger) Sub(other int) RInteger
- func (i RInteger) SubRInt(other RInteger) RInteger
- func (i RInteger) Succ() RInteger
- func (i RInteger) Times(fn func(RInteger))
- func (i RInteger) ToBase(base RInteger) RString
- func (i RInteger) ToBin() RString
- func (i RInteger) ToFloat() float64
- func (i RInteger) ToHex() RString
- func (i RInteger) ToInt() RInteger
- func (i RInteger) ToInteger() RInteger
- func (i RInteger) ToOct() RString
- func (i RInteger) ToRString() RString
- func (i RInteger) ToRational() *big.Rat
- func (i RInteger) ToString() string
- func (i RInteger) Truncate() RInteger
- func (i RInteger) TruncateWithPrecision(digits RInteger) RInteger
- func (i RInteger) UpTo(limit RInteger, fn func(RInteger))
- func (i RInteger) Value() int
- func (i RInteger) Zero() bool
- type RString
- func (s RString) Capitalize() RString
- func (s RString) Center(width int, padStr ...string) RString
- func (s RString) Chars() RArray
- func (s RString) Chomp() RString
- func (s RString) Concat(other RString) RString
- func (s RString) Count(substr string) int
- func (s RString) Downcase() RString
- func (s RString) Each(fn func(RString))
- func (s RString) EachLine(fn func(RString))
- func (s RString) Empty() bool
- func (s RString) EndsWith(suffix string) bool
- func (s RString) Equal(other Object) bool
- func (s RString) Gsub(pattern, repl string) RString
- func (s RString) Include(substr string) bool
- func (s RString) Index(substr string) int
- func (s RString) Inspect() string
- func (s RString) Length() int
- func (s RString) Ljust(width int, padStr ...string) RString
- func (s RString) Match(pattern string) bool
- func (s RString) Ord() int
- func (s RString) RIndex(substr string) int
- func (s RString) ReplaceAll(old, new string) RString
- func (s RString) Reverse() RString
- func (s RString) Rjust(width int, padStr ...string) RString
- func (s RString) Size() int
- func (s RString) Slice(start, end int) RString
- func (s RString) SliceFrom(start int) RString
- func (s RString) Split(sep string) RArray
- func (s RString) StartsWith(prefix string) bool
- func (s RString) Strip() RString
- func (s RString) Sub(pattern, repl string) RString
- func (s RString) SwapCase() RString
- func (s RString) Times(n int) RString
- func (s RString) ToCamelCase() RString
- func (s RString) ToInt() (int, error)
- func (s RString) ToSnakeCase() RString
- func (s RString) ToString() string
- func (s RString) Upcase() RString
Constants ¶
const (
// HashClass 定义了哈希表的类名
HashClass = "Hash"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseObject ¶
type BaseObject struct {
// contains filtered or unexported fields
}
BaseObject 提供 Object 接口的基本实现
func NewBaseObject ¶
func NewBaseObject(className string) BaseObject
NewBaseObject 创建一个新的 BaseObject
type Method ¶
type Method struct { Name string Function MethodFunc IsClass bool // 是否为类方法 }
Method 表示一个方法
type Object ¶
type Object interface { // ToString 返回对象的字符串表示 ToString() string // Class 返回对象的类名 Class() string // IsA 检查对象是否为指定类型 IsA(className string) bool // Equal 比较两个对象是否相等 Equal(other Object) bool }
Object 是所有 R 类型的基础接口
type RArray ¶
type RArray struct { BaseObject // contains filtered or unexported fields }
RArray 实现了类似 Ruby 的数组功能
func (RArray) EachWithIndex ¶
EachWithIndex 对数组中的每个元素及其索引执行操作
type RClass ¶
type RClass struct {
// contains filtered or unexported fields
}
RClass 表示一个 Ruby 风格的类
func (*RClass) AttrAccessor ¶
AttrAccessor 定义属性访问器
func (*RClass) DefineClassMethod ¶
DefineClassMethod 定义类方法
func (*RClass) DefineEigenMethod ¶
DefineEigenMethod 为单个对象定义方法
func (*RClass) DefineMethod ¶
DefineMethod 定义实例方法
func (*RClass) GetInstanceVar ¶
GetInstanceVar 获取实例变量
func (*RClass) GetMethodDirectly ¶
GetMethodDirectly 直接获取方法
func (*RClass) MethodMissing ¶
MethodMissing 设置方法缺失处理器
func (*RClass) SetInstanceVar ¶
SetInstanceVar 设置实例变量
type RHash ¶
type RHash struct { BaseObject // contains filtered or unexported fields }
RHash 实现了类似 Ruby 的哈希表功能
func (*RHash) CompareByIdentityQ ¶
CompareByIdentityQ 检查哈希表是否使用身份比较
func (*RHash) TransformKeys ¶
TransformKeys 返回一个新的哈希表,其中的键经过转换函数处理
func (*RHash) TransformValues ¶
TransformValues 返回一个新的哈希表,其中的值经过转换函数处理
type RInteger ¶
type RInteger struct { BaseObject // contains filtered or unexported fields }
RInteger 实现了类似 Ruby 的整数功能
func (RInteger) CeilWithPrecision ¶
CeilWithPrecision 返回整数指定精度的向上取整结果
func (RInteger) FloorWithPrecision ¶
FloorWithPrecision 返回整数指定精度的向下取整结果
func (RInteger) ModuloRInt ¶
ModuloRInt 返回两个 RInteger 的余数(ModRInt 的别名)
func (RInteger) RightShift ¶
RightShift 返回整数右移指定位数的结果
func (RInteger) RoundWithPrecision ¶
RoundWithPrecision 返回整数指定精度的四舍五入结果
func (RInteger) TruncateWithPrecision ¶
TruncateWithPrecision 返回整数指定精度的截断结果
type RString ¶
type RString struct { BaseObject // contains filtered or unexported fields }
RString 实现了类似 Ruby 的字符串功能
func (RString) ReplaceAll ¶
ReplaceAll 替换字符串中的所有匹配项
func (RString) StartsWith ¶
StartsWith 检查字符串是否以指定的前缀开始