# Class: YARD::Serializers::ProcessSerializer

Inherits:
  Base
  - Object
  - Base
  - YARD::Serializers::ProcessSerializer
  show all

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!")

## Instance Method Summary collapse

- #initialize(cmd) ⇒ ProcessSerializer constructor

  Creates a new ProcessSerializer for the shell command `cmd`.

- #serialize(_object, data) ⇒ Object

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

## Constructor Details

### #initialize(cmd) ⇒ `ProcessSerializer`

Creates a new ProcessSerializer for the shell command `cmd`

Parameters:

- cmd (`String`) —

  the command that will accept data on stdin

    13
    14
    15

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

    def initialize(cmd)
      @cmd = cmd
    end

## Instance Method Details

### #serialize(_object, data) ⇒ `Object`

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

    19
    20
    21

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

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