Class: Markdownator::Converters::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/markdownator/converters/base.rb

Overview

Abstract base class for all converters.

A converter is asked, in priority order, whether it ‘accepts?` a stream; the first one that does has its `convert` called. Subclasses must override both methods. The stream passed in is a rewound IO positioned at byte 0.

Direct Known Subclasses

Csv, Docx, Epub, Html, Image, Json, Pdf, PlainText, Pptx, Xlsx, Xml, Zip

Instance Method Summary collapse

Instance Method Details

#accepts?(_io, _stream_info) ⇒ Boolean

Returns whether this converter can handle the given stream.

Returns:

  • (Boolean)

    whether this converter can handle the given stream.

Raises:

  • (NotImplementedError)


12
13
14
# File 'lib/markdownator/converters/base.rb', line 12

def accepts?(_io, _stream_info)
  raise NotImplementedError, "#{self.class} must implement #accepts?"
end

#convert(_io, _stream_info, **_options) ⇒ Markdownator::Result

Returns:

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/markdownator/converters/base.rb', line 17

def convert(_io, _stream_info, **_options)
  raise NotImplementedError, "#{self.class} must implement #convert"
end