Module: Rucc::Libc

Defined in:
lib/rucc/libc.rb

Overview

Emulate libc

Class Method Summary collapse

Class Method Details

.isalnum(c) ⇒ Object

same with isalnum in libc

Parameters:

  • c (Char)


31
32
33
# File 'lib/rucc/libc.rb', line 31

def isalnum(c)
  "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".freeze.include?(c)
end

.isalpha(c) ⇒ Object

same with isalpha in libc

Parameters:

  • c (Char)


25
26
27
# File 'lib/rucc/libc.rb', line 25

def isalpha(c)
  "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".freeze.include?(c)
end

.isdigit(c) ⇒ Object

same with isdigit in libc

Parameters:

  • c (Char)


13
14
15
# File 'lib/rucc/libc.rb', line 13

def isdigit(c)
  "0123456789".freeze.include?(c)
end

.isprint(c) ⇒ Object

TODO(south37) Impl same logic with isprint in libc



42
43
44
# File 'lib/rucc/libc.rb', line 42

def isprint(c)
  isalnum(c) || ispunct(c) || isspace(c)
end

.ispunct(c) ⇒ Object

TODO(south37) Impl same logic with ispunct in libc

Parameters:

  • c (Char)


37
38
39
# File 'lib/rucc/libc.rb', line 37

def ispunct(c)
  '!"#$%&\'()*+,-./:;<=>?@[\]^_`{|}~'.include?(c)
end

.isspace(c) ⇒ Object

same with isspace in libc

Parameters:

  • c (Char)


7
8
9
# File 'lib/rucc/libc.rb', line 7

def isspace(c)
  "\x20\x0c\x0a\x0d\x09\x0b".freeze.include?(c)
end

.isxdigit(c) ⇒ Object

same with isdigit in libc

Parameters:

  • c (Char)


19
20
21
# File 'lib/rucc/libc.rb', line 19

def isxdigit(c)
  "0123456789abcdefABCDEF".freeze.include?(c)
end