Class: IRB::OutputMethod
Overview
OutputMethod
StdioOutputMethod
Direct Known Subclasses
Instance Method Summary collapse
- #foo(format) ⇒ Object
- #parse_printf_format(format, opts) ⇒ Object
- #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
#foo(format) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/irb/output-method.rb', line 48 def foo(format) pos = 0 inspects = [] format.scan(/%[#0\-+ ]?(\*(?=[^0-9])|\*[1-9][0-9]*\$|[1-9][0-9]*(?=[^0-9]))?(\.(\*(?=[^0-9])|\*[1-9][0-9]*\$|[1-9][0-9]*(?=[^0-9])))?(([1-9][0-9]*\$)*)([diouxXeEfgGcsb%])/) {|f, p, pp, pos, new_pos, c| puts [f, p, pp, pos, new_pos, c].join("!") pos = new_pos if new_pos if c == "I" inspects.push pos.to_i (f||"")+(p||"")+(pp||"")+(pos||"")+"s" else $& end } end |
#parse_printf_format(format, opts) ⇒ Object
44 45 46 |
# File 'lib/irb/output-method.rb', line 44 def parse_printf_format(format, opts) return format, opts if $1.size % 2 == 1 end |
#pp(*objs) ⇒ Object
70 71 72 |
# File 'lib/irb/output-method.rb', line 70 def pp(*objs) puts(*objs.collect{|obj| obj.inspect}) end |
#ppx(prefix, *objs) ⇒ Object
74 75 76 |
# File 'lib/irb/output-method.rb', line 74 def ppx(prefix, *objs) puts(*objs.collect{|obj| prefix+obj.inspect}) end |
#print(*opts) ⇒ Object
22 23 24 |
# File 'lib/irb/output-method.rb', line 22 def print(*opts) IRB.fail NotImplementError, "print" end |
#printf(format, *opts) ⇒ Object
extend printf
31 32 33 34 35 36 |
# File 'lib/irb/output-method.rb', line 31 def printf(format, *opts) if /(%*)%I/ =~ format format, opts = parse_printf_format(format, opts) end print sprintf(format, *opts) end |
#printn(*opts) ⇒ Object
26 27 28 |
# File 'lib/irb/output-method.rb', line 26 def printn(*opts) print opts.join(" "), "\n" end |
#puts(*objs) ⇒ Object
63 64 65 66 67 68 |
# File 'lib/irb/output-method.rb', line 63 def puts(*objs) for obj in objs print(*obj) print "\n" end end |