123456789_123456789_123456789_123456789_123456789_

Class: YARD::Serializers::ProcessSerializer

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/process_serializer.rb

Overview

Serializes an object to a process (like less)

Examples:

Serializing to a pager (less)

serializer = ProcessSerializer.new('less')
serializer.serialize(object, "data!")

Class Method Summary

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

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(cmd) ⇒ ProcessSerializer

Creates a new ProcessSerializer for the shell command cmd

Parameters:

  • cmd (String)

    the command that will accept data on stdin

[ GitHub ]

  
# File 'lib/yard/serializers/process_serializer.rb', line 13

def initialize(cmd)
  @cmd = cmd
end

Instance Method Details

#serialize(_object, data)

Overrides serialize behaviour and writes data to standard input of the associated command

[ GitHub ]

  
# File 'lib/yard/serializers/process_serializer.rb', line 19

def serialize(_object, data)
  IO.popen(@cmd, 'w') {|io| io.write(data) }
end