Class: IRB::OutputMethod
Overview
OutputMethod
StdioOutputMethod
Direct Known Subclasses
Instance Method Summary collapse
-
#parse_printf_format(format, opts) ⇒ Object
% <flag> [#0- +] <minimum field width> (*|*[1-9]*$|[1-9]*) <precision>.(*|*[0-9]*$|[0-9]*|)? #<length modifier>(hh|h|l|ll|L|q|j|z|t) <conversion specifier>.
- #pp(*objs) ⇒ Object
- #ppx(prefix, *objs) ⇒ Object
- #print(*opts) ⇒ Object
-
#printf(format, *opts) ⇒ Object
extend printf.
- #printn(*opts) ⇒ Object
- #puts(*objs) ⇒ Object
Instance Method Details
#parse_printf_format(format, opts) ⇒ Object
% <flag> [#0- +] <minimum field width> (*|*[1-9]*$|[1-9]*) <precision>.(*|*[0-9]*$|[0-9]*|)? #<length modifier>(hh|h|l|ll|L|q|j|z|t) <conversion specifier>
43 44 45 |
# File 'lib/irb/output-method.rb', line 43 def parse_printf_format(format, opts) return format, opts if $1.size % 2 == 1 end |
#pp(*objs) ⇒ Object
54 55 56 |
# File 'lib/irb/output-method.rb', line 54 def pp(*objs) puts(*objs.collect{|obj| obj.inspect}) end |
#ppx(prefix, *objs) ⇒ Object
58 59 60 |
# File 'lib/irb/output-method.rb', line 58 def ppx(prefix, *objs) puts(*objs.collect{|obj| prefix+obj.inspect}) end |
#print(*opts) ⇒ Object
21 22 23 |
# File 'lib/irb/output-method.rb', line 21 def print(*opts) IRB.fail NotImplementError, "print" end |
#printf(format, *opts) ⇒ Object
extend printf
30 31 32 33 34 35 |
# File 'lib/irb/output-method.rb', line 30 def printf(format, *opts) if /(%*)%I/ =~ format format, opts = parse_printf_format(format, opts) end print sprintf(format, *opts) end |
#printn(*opts) ⇒ Object
25 26 27 |
# File 'lib/irb/output-method.rb', line 25 def printn(*opts) print opts.join(" "), "\n" end |
#puts(*objs) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/irb/output-method.rb', line 47 def puts(*objs) for obj in objs print(*obj) print "\n" end end |