Class: ObjectInspector::TemplatingFormatter

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

Overview

Specializes on BaseFormatter to build the default inspect output format using String templates.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.templatesObject

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



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

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)


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

def call
  if wrapped_object_inspection_result
    build_wrapped_object_string
  else
    build_string
  end
end