Module: CBOR::PP::PPMethods
- Included in:
- CBOR::PP
- Defined in:
- lib/cbor-pp.rb
Instance Method Summary collapse
-
#comma_breakable ⇒ Object
XXX: a nested group that is broken should not have things added at the end.
-
#pp(obj) ⇒ Object
Adds
obj
to the pretty printing buffer using Object#cbor_pp. -
#pp_hash(obj, anno) ⇒ Object
A pretty print for a Hash.
-
#seplist(list, sep = nil, iter_method = :each) ⇒ Object
:yield: element.
Instance Method Details
#comma_breakable ⇒ Object
XXX: a nested group that is broken should not have things added at the end
29 30 31 32 |
# File 'lib/cbor-pp.rb', line 29 def comma_breakable text ',' fill_breakable end |
#pp(obj) ⇒ Object
Adds obj
to the pretty printing buffer using Object#cbor_pp.
24 25 26 |
# File 'lib/cbor-pp.rb', line 24 def pp(obj) group {obj.cbor_pp self} end |
#pp_hash(obj, anno) ⇒ Object
A pretty print for a Hash
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/cbor-pp.rb', line 48 def pp_hash(obj, anno) s = "#{anno}{" group(1, s, '}') { seplist(obj, nil, :each_pair) {|k, v| group { pp k text ':' group(1) { breakable ' ' pp v } } } } end |
#seplist(list, sep = nil, iter_method = :each) ⇒ Object
:yield: element
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cbor-pp.rb', line 34 def seplist(list, sep=nil, iter_method=:each) # :yield: element sep ||= lambda { comma_breakable } first = true list.__send__(iter_method) {|*v| if first first = false else sep.call end yield(*v) } end |