Class: ObjectInspector::BaseFormatter

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

Overview

An abstract base class that interfaces with Inspector objects to combine the supplied #identification, #flags, #info, and #name strings into a friendly “inspect” String.

Direct Known Subclasses

CombiningFormatter, TemplatingFormatter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(inspector) ⇒ BaseFormatter

Returns a new instance of BaseFormatter.

Parameters:



10
11
12
# File 'lib/object_inspector/formatters/base_formatter.rb', line 10

def initialize(inspector)
  @inspector = inspector
end

Instance Attribute Details

#inspectorObject (readonly)

Returns the value of attribute inspector.



7
8
9
# File 'lib/object_inspector/formatters/base_formatter.rb', line 7

def inspector
  @inspector
end

Instance Method Details

#callString

Perform the formatting routine.

Returns:

  • (String)

Raises:

  • (NotImplementedError)


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

def call
  raise(NotImplementedError)
end

#flagsString, NilClass

Delegates to Inspector#flags.

Returns:

  • (String)

    If given.

  • (NilClass)

    If not given.



41
42
43
# File 'lib/object_inspector/formatters/base_formatter.rb', line 41

def flags
  @flags ||= inspector.flags
end

#identificationString

Delegates to Inspector#identification.

Returns:

  • (String)

    If given.



33
34
35
# File 'lib/object_inspector/formatters/base_formatter.rb', line 33

def identification
  @identification ||= inspector.identification
end

#infoString, NilClass

Delegates to Inspector#info.

Returns:

  • (String)

    If given.

  • (NilClass)

    If not given.



57
58
59
# File 'lib/object_inspector/formatters/base_formatter.rb', line 57

def info
  @info ||= inspector.info
end

#issuesString, NilClass

Delegates to Inspector#issues.

Returns:

  • (String)

    If given.

  • (NilClass)

    If not given.



49
50
51
# File 'lib/object_inspector/formatters/base_formatter.rb', line 49

def issues
  @issues ||= inspector.issues
end

#nameString, NilClass

Delegates to Inspector#name.

Returns:

  • (String)

    If given.

  • (NilClass)

    If not given.



65
66
67
# File 'lib/object_inspector/formatters/base_formatter.rb', line 65

def name
  @name ||= inspector.name
end

#wrapped_object_inspection_resultString, NilClass

Returns:

  • (String)

    If given.

  • (NilClass)

    If not given.



25
26
27
28
# File 'lib/object_inspector/formatters/base_formatter.rb', line 25

def wrapped_object_inspection_result
  @wrapped_object_inspection_result ||=
    inspector.wrapped_object_inspection_result
end