Class: ObjectInspector::Inspector
- Inherits:
-
Object
- Object
- ObjectInspector::Inspector
- Defined in:
- lib/object_inspector/inspector.rb
Overview
ObjectInspector::Inspector organizes inspection of the associated @object via the passed in options and via a BaseFormatter instance.
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Class Method Summary collapse
-
.inspect(object, **kargs) ⇒ String
Shortcuts the instantiation -> #to_s flow that would normally be required to use ObjectInspector::Inspector.
Instance Method Summary collapse
-
#flags ⇒ String, NilClass
Boolean flags/states applicable to @object.
-
#identification ⇒ String
Core object identification details, such as the @object class name and any core-level attributes.
-
#info ⇒ String, NilClass
Informational details applicable to @object.
-
#initialize(object, scope: ObjectInspector.configuration.default_scope, formatter: ObjectInspector.configuration.formatter_class, **kargs) ⇒ Inspector
constructor
A new instance of Inspector.
-
#issues ⇒ String, NilClass
Issues/Warnings applicable to @object.
-
#name ⇒ String, NilClass
A human-friendly identifier for @object.
-
#to_s ⇒ String
Generate the formatted inspect String.
-
#wrapped_object_inspection_result ⇒ String, NilClass
Generate the inspect String for the wrapped object, if present.
Constructor Details
#initialize(object, scope: ObjectInspector.configuration.default_scope, formatter: ObjectInspector.configuration.formatter_class, **kargs) ⇒ Inspector
Returns a new instance of Inspector.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/object_inspector/inspector.rb', line 29 def initialize( object, scope: ObjectInspector.configuration.default_scope, formatter: ObjectInspector.configuration.formatter_class, **kargs) @object = object @scope = Conversions.Scope(scope) @formatter_klass = formatter @kargs = kargs end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
8 9 10 |
# File 'lib/object_inspector/inspector.rb', line 8 def object @object end |
Class Method Details
.inspect(object, **kargs) ⇒ String
Shortcuts the instantiation -> #to_s flow that would normally be required to use ObjectInspector::Inspector.
14 15 16 |
# File 'lib/object_inspector/inspector.rb', line 14 def self.inspect(object, **kargs) new(object, **kargs).to_s end |
Instance Method Details
#flags ⇒ String, NilClass
Boolean flags/states applicable to @object.
73 74 75 |
# File 'lib/object_inspector/inspector.rb', line 73 def flags value(key: :flags) end |
#identification ⇒ String
Core object identification details, such as the @object class name and any core-level attributes.
65 66 67 |
# File 'lib/object_inspector/inspector.rb', line 65 def identification (value(key: :identification) || @object.class).to_s end |
#info ⇒ String, NilClass
Informational details applicable to @object.
89 90 91 |
# File 'lib/object_inspector/inspector.rb', line 89 def info value(key: :info) end |
#issues ⇒ String, NilClass
Issues/Warnings applicable to @object.
81 82 83 |
# File 'lib/object_inspector/inspector.rb', line 81 def issues value(key: :issues) end |
#name ⇒ String, NilClass
A human-friendly identifier for @object.
97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/object_inspector/inspector.rb', line 97 def name key = :name if @kargs.key?(key) value(key: key) else interrogate_object_inspect_method(key) || interrogate_object(method_name: :display_name, kargs: object_method_keyword_arguments) end end |
#to_s ⇒ String
Generate the formatted inspect String.
43 44 45 |
# File 'lib/object_inspector/inspector.rb', line 43 def to_s formatter.call end |
#wrapped_object_inspection_result ⇒ String, NilClass
Generate the inspect String for the wrapped object, if present.
51 52 53 54 55 56 57 58 59 |
# File 'lib/object_inspector/inspector.rb', line 51 def wrapped_object_inspection_result return unless object_is_a_wrapper? self.class.inspect( extract_wrapped_object, scope: @scope, formatter: @formatter_klass, kargs: @kargs) end |