class YARD::Serializers::StdoutSerializer
A serializer that writes data to standard output.
def initialize(wrap = nil)
-
wrap
(Fixnum, nil
) -- if wrap is a number, wraps text to +wrap+
def initialize(wrap = nil) @wrap = wrap end
def serialize(_object, data)
def serialize(_object, data) print(@wrap ? word_wrap(data, @wrap) : data) end
def word_wrap(text, _length = 80)
-
(String)
- the wrapped text
Parameters:
-
_length
(Fixnum
) -- the column length to wrap to -
text
(String
) -- the text to wrap
def word_wrap(text, _length = 80) # See ruby-talk/10655 / Ernest Ellingson text.gsub(/\t/, " ").gsub(/.{1,50}(?:\s|\Z)/) do ($& + 5.chr).gsub(/\n\005/, "\n").gsub(/\005/, "\n") end end