Class: YARD::Serializers::StdoutSerializer
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Base
|
|
Instance Chain:
self,
Base
|
|
Inherits: |
YARD::Serializers::Base
|
Defined in: | lib/yard/serializers/stdout_serializer.rb |
Overview
A serializer that writes data to standard output.
Class Method Summary
-
.new(wrap = nil) ⇒ StdoutSerializer
constructor
Creates a serializer to print text to stdout.
Base
- Inherited
.new | Creates a new serializer with options. |
Instance Attribute Summary
Base
- Inherited
#options | All serializer options are saved so they can be passed to other serializers. |
Instance Method Summary
-
#serialize(_object, data)
Overrides serialize behaviour to write data to standard output.
-
#word_wrap(text, _length = 80) ⇒ String
private
Wraps text to a specific column length.
Base
- Inherited
#after_serialize | Called after serialization. |
#before_serialize | Called before serialization. |
#exists? | Returns whether an object has been serialized. |
#serialize | Serializes an object. |
#serialized_path | The serialized path of an object. |
Constructor Details
.new(wrap = nil) ⇒ StdoutSerializer
Creates a serializer to print text to stdout
# File 'lib/yard/serializers/stdout_serializer.rb', line 10
def initialize(wrap = nil) @wrap = wrap end
Instance Method Details
#serialize(_object, data)
Overrides serialize behaviour to write data to standard output
# File 'lib/yard/serializers/stdout_serializer.rb', line 15
def serialize(_object, data) print(@wrap ? word_wrap(data, @wrap) : data) end
#word_wrap(text, _length = 80) ⇒ String (private)
Wraps text to a specific column length
# File 'lib/yard/serializers/stdout_serializer.rb', line 26
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