Class: ObjectInspector::TemplatingFormatter

Inherits:
BaseFormatter show all
Defined in:
lib/object_inspector/formatters/templating_formatter.rb

Overview

ObjectInspector::TemplatingFormatter specializes on BaseFormatter to return the standard/default inspect output format via String templates.

Instance Attribute Summary

Attributes inherited from BaseFormatter

#inspector

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseFormatter

#flags, #identification, #info, #initialize, #issues, #name, #wrapped_object_inspection_result

Constructor Details

This class inherits a constructor from ObjectInspector::BaseFormatter

Class Method Details

.templatesObject

Named String templates. Used by the build_* methods, these templates determine the format of the built output Strings.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/object_inspector/formatters/templating_formatter.rb', line 15

def self.templates
  @templates ||= {
    base: "<%s>",
    name: "<%s :: %s>",
    issues_and_name: "<%s !!%s!! :: %s>",
    flags_and_name: "<%s(%s) :: %s>",
    info_and_name: "<%s %s :: %s>",
    issues_and_info_and_name: "<%s !!%s!! %s :: %s>",
    flags_and_info: "<%s(%s) %s>",
    flags_and_issues: "<%s(%s) !!%s!!>",
    issues_and_info: "<%s !!%s!! %s>",
    flags_and_issues_and_info: "<%s(%s) !!%s!! %s>",
    flags_and_issues_and_name: "<%s(%s) !!%s!! :: %s>",
    flags_and_info_and_name: "<%s(%s) %s :: %s>",
    flags_and_issues_and_info_and_name: "<%s(%s) !!%s!! %s :: %s>",
    flags: "<%s(%s)>",
    issues: "<%s !!%s!!>",
    info: "<%s %s>",
  }.freeze
end

Instance Method Details

#callString

Perform the formatting routine.

Returns:

  • (String)


39
40
41
42
43
44
45
# File 'lib/object_inspector/formatters/templating_formatter.rb', line 39

def call
  if wrapped_object_inspection_result
    build_wrapped_object_string
  else
    build_string
  end
end