Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby27/share/ruby/irb
File: output-method.rb
# frozen_string_literal: false
[0] Fix | Delete
#
[1] Fix | Delete
# output-method.rb - output methods used by irb
[2] Fix | Delete
# $Release Version: 0.9.6$
[3] Fix | Delete
# $Revision$
[4] Fix | Delete
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
[5] Fix | Delete
#
[6] Fix | Delete
# --
[7] Fix | Delete
#
[8] Fix | Delete
#
[9] Fix | Delete
#
[10] Fix | Delete
[11] Fix | Delete
module IRB
[12] Fix | Delete
# An abstract output class for IO in irb. This is mainly used internally by
[13] Fix | Delete
# IRB::Notifier. You can define your own output method to use with Irb.new,
[14] Fix | Delete
# or Context.new
[15] Fix | Delete
class OutputMethod
[16] Fix | Delete
class NotImplementedError < StandardError
[17] Fix | Delete
def initialize(val)
[18] Fix | Delete
super("Need to define `#{val}'")
[19] Fix | Delete
end
[20] Fix | Delete
end
[21] Fix | Delete
[22] Fix | Delete
# Open this method to implement your own output method, raises a
[23] Fix | Delete
# NotImplementedError if you don't define #print in your own class.
[24] Fix | Delete
def print(*opts)
[25] Fix | Delete
raise NotImplementedError, "print"
[26] Fix | Delete
end
[27] Fix | Delete
[28] Fix | Delete
# Prints the given +opts+, with a newline delimiter.
[29] Fix | Delete
def printn(*opts)
[30] Fix | Delete
print opts.join(" "), "\n"
[31] Fix | Delete
end
[32] Fix | Delete
[33] Fix | Delete
# Extends IO#printf to format the given +opts+ for Kernel#sprintf using
[34] Fix | Delete
# #parse_printf_format
[35] Fix | Delete
def printf(format, *opts)
[36] Fix | Delete
if /(%*)%I/ =~ format
[37] Fix | Delete
format, opts = parse_printf_format(format, opts)
[38] Fix | Delete
end
[39] Fix | Delete
print sprintf(format, *opts)
[40] Fix | Delete
end
[41] Fix | Delete
[42] Fix | Delete
# Returns an array of the given +format+ and +opts+ to be used by
[43] Fix | Delete
# Kernel#sprintf, if there was a successful Regexp match in the given
[44] Fix | Delete
# +format+ from #printf
[45] Fix | Delete
#
[46] Fix | Delete
# %
[47] Fix | Delete
# <flag> [#0- +]
[48] Fix | Delete
# <minimum field width> (\*|\*[1-9][0-9]*\$|[1-9][0-9]*)
[49] Fix | Delete
# <precision>.(\*|\*[1-9][0-9]*\$|[1-9][0-9]*|)?
[50] Fix | Delete
# #<length modifier>(hh|h|l|ll|L|q|j|z|t)
[51] Fix | Delete
# <conversion specifier>[diouxXeEfgGcsb%]
[52] Fix | Delete
def parse_printf_format(format, opts)
[53] Fix | Delete
return format, opts if $1.size % 2 == 1
[54] Fix | Delete
end
[55] Fix | Delete
[56] Fix | Delete
# Calls #print on each element in the given +objs+, followed by a newline
[57] Fix | Delete
# character.
[58] Fix | Delete
def puts(*objs)
[59] Fix | Delete
for obj in objs
[60] Fix | Delete
print(*obj)
[61] Fix | Delete
print "\n"
[62] Fix | Delete
end
[63] Fix | Delete
end
[64] Fix | Delete
[65] Fix | Delete
# Prints the given +objs+ calling Object#inspect on each.
[66] Fix | Delete
#
[67] Fix | Delete
# See #puts for more detail.
[68] Fix | Delete
def pp(*objs)
[69] Fix | Delete
puts(*objs.collect{|obj| obj.inspect})
[70] Fix | Delete
end
[71] Fix | Delete
[72] Fix | Delete
# Prints the given +objs+ calling Object#inspect on each and appending the
[73] Fix | Delete
# given +prefix+.
[74] Fix | Delete
#
[75] Fix | Delete
# See #puts for more detail.
[76] Fix | Delete
def ppx(prefix, *objs)
[77] Fix | Delete
puts(*objs.collect{|obj| prefix+obj.inspect})
[78] Fix | Delete
end
[79] Fix | Delete
[80] Fix | Delete
end
[81] Fix | Delete
[82] Fix | Delete
# A standard output printer
[83] Fix | Delete
class StdioOutputMethod < OutputMethod
[84] Fix | Delete
# Prints the given +opts+ to standard output, see IO#print for more
[85] Fix | Delete
# information.
[86] Fix | Delete
def print(*opts)
[87] Fix | Delete
STDOUT.print(*opts)
[88] Fix | Delete
end
[89] Fix | Delete
end
[90] Fix | Delete
end
[91] Fix | Delete
[92] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function