Class: Rescuetime::Formatters::BaseFormatter Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/rescuetime/formatters/base_formatter.rb

Overview

This class is abstract.

Subclass and override BaseFormatter.name and BaseFormatter.format to implement a custom formatter

Base class for report formatters

See Also:

Since:

  • v0.4.0

Direct Known Subclasses

ArrayFormatter, CSVFormatter

Class Method Summary collapse

Class Method Details

.descendentsArray<Class>

Returns all classes descended from the current class

Examples:

require 'rescuetime/formatters/array_formatter'
base_formatter = Rescuetime::Formatters::BaseFormatter

base_formatter.descendents
#=> [Rescuetime::Formatters::ArrayFormatter]

Returns:

  • (Array<Class>)

    all loaded descendents of the current class

Since:

  • v0.4.0



42
43
44
# File 'lib/rescuetime/formatters/base_formatter.rb', line 42

def self.descendents
  ObjectSpace.each_object(Class).select { |klass| klass < self }
end

.format(_report) ⇒ Object

Formats the rescuetime report from CSV to a user-defined format

Parameters:

  • _report (CSV)

    a csv-formatted report

Returns:

  • a report formatted to your specifications

Raises:

  • (NotImplementedError)

    this method is not yet implemented

Since:

  • v0.4.0



27
28
29
30
# File 'lib/rescuetime/formatters/base_formatter.rb', line 27

def self.format(_report)
  raise NotImplementedError,
        'you have not defined report formatting instructions'
end

.nameString

Returns the name of your formatter

Returns:

  • (String)

    a name for your report formatter

Raises:

  • (NotImplementedError)

    this method is not yet implemented

Since:

  • v0.4.0



17
18
19
# File 'lib/rescuetime/formatters/base_formatter.rb', line 17

def self.name
  raise NotImplementedError, 'you have not defined a report name'
end