-
Notifications
You must be signed in to change notification settings - Fork 0
/
base_formatter.rb
69 lines (60 loc) · 1.57 KB
/
base_formatter.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# frozen_string_literal: true
# ObjectInspector::BaseFormatter is an abstract base class that interfaces
# with {ObjectInspector::Inspector} objects to combine the supplied
# {#identification}, {#flags}, {#info}, and {#name} strings into a friendly
# "inspect" String.
class ObjectInspector::BaseFormatter
attr_reader :inspector
# @param inspector [ObjectInspector::Inspector]
def initialize(inspector)
@inspector = inspector
end
# Perform the formatting routine.
#
# @return [String]
def call
raise NotImplementedError
end
# Delegates to {Inspector#wrapped_object_inspection_result}.
#
# @return [String] if given
# @return [NilClass] if not given
def wrapped_object_inspection_result
@wrapped_object_inspection_result ||=
@inspector.wrapped_object_inspection_result
end
# Delegates to {Inspector#identification}.
#
# @return [String] if given
def identification
@identification ||= @inspector.identification
end
# Delegates to {Inspector#flags}.
#
# @return [String] if given
# @return [NilClass] if not given
def flags
@flags ||= @inspector.flags
end
# Delegates to {Inspector#issues}.
#
# @return [String] if given
# @return [NilClass] if not given
def issues
@issues ||= @inspector.issues
end
# Delegates to {Inspector#info}.
#
# @return [String] if given
# @return [NilClass] if not given
def info
@info ||= @inspector.info
end
# Delegates to {Inspector#name}.
#
# @return [String] if given
# @return [NilClass] if not given
def name
@name ||= @inspector.name
end
end