fn digits(vm: &mut VM, self_val: Value, args: &Args2) -> VMResult {
    args.check_args_range(0, 1)?;
    let base = if args.len() == 0 {
        10
    } else {
        match vm[0].coerce_to_fixnum("Arg")? {
            i if i < 0 => return Err(RubyError::argument("Negative radix.")),
            0 => return Err(RubyError::argument("Invalid radix 0.")),
            i => i,
        }
    };
    let mut ary = vec![];
    let mut self_ = self_val.as_fixnum().unwrap();
    if self_ < 0 {
        return Err(RubyError::math_domain("Out of domain."));
    }
    loop {
        let r = self_ % base;
        self_ = self_ / base;
        if r == 0 {
            break;
        }
        ary.push(Value::integer(r));
    }
    if ary.len() == 0 {
        ary.push(Value::integer(0))
    }
    Ok(Value::array_from(ary))
}
digits -> Integer
digits(base) -> Integer

https://docs.ruby-lang.org/ja/latest/method/Integer/i/digits.html
ruruby/src/builtin/integer.rs