Module: KernAux
- Defined in:
- lib/kernaux.rb,
lib/kernaux/ntoa.rb,
lib/kernaux/assert.rb,
lib/kernaux/errors.rb,
lib/kernaux/cmdline.rb,
lib/kernaux/version.rb,
ext/default/main.c
Overview
Binding to libkernaux - auxiliary library for kernel development.
Defined Under Namespace
Modules: Version Classes: AssertError, CmdlineError, Error, InvalidNtoaBaseError, TooLongNtoaPrefixError
Constant Summary collapse
- DEFAULT_ASSERT_CB =
Default callback for assertions.
@assert_cb = lambda { |file, line, msg| raise AssertError, "#{file}:#{line}:#{msg}" }
- VERSION =
Gem version.
'0.7.0'
Class Attribute Summary collapse
-
.assert_cb ⇒ Proc
Panic callback.
Class Method Summary collapse
-
.assert_do(file, line, msg) ⇒ nil
Raise assertion with explicit file, line and message.
-
.cmdline(str) ⇒ Array<String>
Parse command line.
-
.itoa(number, base, prefix) ⇒ String
Convert
int64_t
to a string in multiple numeral systems. -
.itoa10(number) ⇒ String
Convert
int64_t
to a decimal string. -
.itoa16(number) ⇒ String
Convert
int64_t
to a hexadecimal string. -
.itoa2(number) ⇒ String
Convert
int64_t
to a binary string. -
.itoa8(number) ⇒ String
Convert
int64_t
to a octal string. -
.panic(msg) ⇒ nil
Raise assertion with implicit file and line, retrieved from
caller
, and explicit message. -
.sprintf ⇒ String
Typical
printf
. -
.utoa(number, base, prefix) ⇒ String
Convert
uint64_t
to a string in multiple numeral systems. -
.utoa10(number) ⇒ String
Convert
uint64_t
to a decimal string. -
.utoa16(number) ⇒ String
Convert
uint64_t
to a hexadecimal string. -
.utoa2(number) ⇒ String
Convert
uint64_t
to a binary string. -
.utoa8(number) ⇒ String
Convert
uint64_t
to a octal string.
Class Attribute Details
.assert_cb ⇒ Proc
Panic callback.
|
# File 'lib/kernaux/assert.rb', line 15
|
Class Method Details
.assert_do(file, line, msg) ⇒ nil
Raise assertion with explicit file, line and message.
|
# File 'lib/kernaux/assert.rb', line 43
|
.cmdline(str) ⇒ Array<String>
Parse command line.
|
# File 'lib/kernaux/cmdline.rb', line 9
|
.itoa(number, base, prefix) ⇒ String
Convert int64_t
to a string in multiple numeral systems.
Base can be a positive or negative integer between 2 and 36, or a symbol
which is an alias to a valid integer value. Positive integers and lowercase
symbols mean lowercase output when base is greater than 10. Negative
integers and uppercase symbols mean uppercase output when base is greater
than 10. Aliases are: :b
, :B
- 2; :o
, :O
- 8; :d
, :D
- 10; :h
,
:x
- 16 (lowercase); :H
, :X
- -10 (uppercase).
|
# File 'lib/kernaux/ntoa.rb', line 32
|
.itoa10(number) ⇒ String
Convert int64_t
to a decimal string.
|
# File 'lib/kernaux/ntoa.rb', line 105
|
.itoa16(number) ⇒ String
Convert int64_t
to a hexadecimal string.
|
# File 'lib/kernaux/ntoa.rb', line 125
|
.itoa2(number) ⇒ String
Convert int64_t
to a binary string.
|
# File 'lib/kernaux/ntoa.rb', line 65
|
.itoa8(number) ⇒ String
Convert int64_t
to a octal string.
|
# File 'lib/kernaux/ntoa.rb', line 85
|
.panic(msg) ⇒ nil
Raise assertion with implicit file and line, retrieved from caller
, and
explicit message.
38 39 40 41 |
# File 'lib/kernaux/assert.rb', line 38 def self.panic(msg) file, line = caller(1..1).first.split(':')[0..1] assert_do file, Integer(line), msg end |
.sprintf ⇒ String
Typical printf
.
18 |
# File 'ext/default/printf.c', line 18
static VALUE rb_KernAux_sprintf(int argc, VALUE *argv, VALUE self);
|
.utoa(number, base, prefix) ⇒ String
Convert uint64_t
to a string in multiple numeral systems.
Base can be a positive or negative integer between 2 and 36, or a symbol
which is an alias to a valid integer value. Positive integers and lowercase
symbols mean lowercase output when base is greater than 10. Negative
integers and uppercase symbols mean uppercase output when base is greater
than 10. Aliases are: :b
, :B
- 2; :o
, :O
- 8; :d
, :D
- 10; :h
,
:x
- 16 (lowercase); :H
, :X
- -10 (uppercase).
|
# File 'lib/kernaux/ntoa.rb', line 9
|
.utoa10(number) ⇒ String
Convert uint64_t
to a decimal string.
|
# File 'lib/kernaux/ntoa.rb', line 95
|
.utoa16(number) ⇒ String
Convert uint64_t
to a hexadecimal string.
|
# File 'lib/kernaux/ntoa.rb', line 115
|
.utoa2(number) ⇒ String
Convert uint64_t
to a binary string.
|
# File 'lib/kernaux/ntoa.rb', line 55
|
.utoa8(number) ⇒ String
Convert uint64_t
to a octal string.
|
# File 'lib/kernaux/ntoa.rb', line 75
|