module Raheui::IO
IO
methods for user input and output.
Public Class Methods
print_chr(value)
click to toggle source
Print an character from character code.
value - The Integer character code to print.
Examples
IO.print_chr(97) # a=> nil IO.print_chr(0xAC00) # 가=> nil # Rescue RangeError IO.print_chr(-1) # [U+..FF]=> nil # Rescue RangeError IO.print_chr(0x110000) # [U+110000]=> nil
Returns nothing.
# File lib/raheui/io.rb, line 55 def self.print_chr(value) # See https://github.com/jruby/jruby/issues/1921. if RUBY_PLATFORM == 'java' && (0xD800 <= value && value <= 0xDFFF || value > 0x10_FFFF) fail RangeError, "invalid codepoint 0x#{value.to_s(16).upcase} in UTF-8" end $stdout.print value.chr(Encoding::UTF_8) rescue RangeError $stdout.print format('[U+%04X]', value) end
print_int(value)
click to toggle source
Print an Integer.
value - The Integer to print.
Examples
IO.print_int(42) # 42=> nil
Returns nothing.
# File lib/raheui/io.rb, line 30 def self.print_int(value) $stdout.print value end
read_chr()
click to toggle source
Read an character from user input.
Returns the Integer character code of the character user entered.
# File lib/raheui/io.rb, line 16 def self.read_chr $stdin.getc.ord end
read_int()
click to toggle source
Read an Integer from user input.
Returns the Integer user entered.
# File lib/raheui/io.rb, line 9 def self.read_int $stdin.gets.to_i end