Class: MismatchInspectable::InspectionOptions
- Inherits:
-
Object
- Object
- MismatchInspectable::InspectionOptions
- Defined in:
- lib/mismatch_inspectable/inspection_options.rb
Instance Attribute Summary collapse
-
#format ⇒ Object
Returns the value of attribute format.
-
#include_class ⇒ Object
Returns the value of attribute include_class.
-
#options ⇒ Object
Returns the value of attribute options.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#recursive ⇒ Object
Returns the value of attribute recursive.
Instance Method Summary collapse
- #comparable_prefix ⇒ Object
- #formatter ⇒ Object
-
#initialize(prefix: "", recursive: false, include_class: true, format: :array) ⇒ InspectionOptions
constructor
A new instance of InspectionOptions.
- #to_h ⇒ Object
- #update_prefix(target_class) ⇒ Object
Constructor Details
#initialize(prefix: "", recursive: false, include_class: true, format: :array) ⇒ InspectionOptions
Returns a new instance of InspectionOptions.
7 8 9 10 11 12 |
# File 'lib/mismatch_inspectable/inspection_options.rb', line 7 def initialize(prefix: "", recursive: false, include_class: true, format: :array) @recursive = recursive @include_class = include_class @prefix = prefix @format = format end |
Instance Attribute Details
#format ⇒ Object
Returns the value of attribute format.
5 6 7 |
# File 'lib/mismatch_inspectable/inspection_options.rb', line 5 def format @format end |
#include_class ⇒ Object
Returns the value of attribute include_class.
5 6 7 |
# File 'lib/mismatch_inspectable/inspection_options.rb', line 5 def include_class @include_class end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/mismatch_inspectable/inspection_options.rb', line 5 def end |
#prefix ⇒ Object
Returns the value of attribute prefix.
5 6 7 |
# File 'lib/mismatch_inspectable/inspection_options.rb', line 5 def prefix @prefix end |
#recursive ⇒ Object
Returns the value of attribute recursive.
5 6 7 |
# File 'lib/mismatch_inspectable/inspection_options.rb', line 5 def recursive @recursive end |
Instance Method Details
#comparable_prefix ⇒ Object
33 34 35 36 |
# File 'lib/mismatch_inspectable/inspection_options.rb', line 33 def comparable_prefix prefixes = prefix.split(".") prefixes.length >= 2 ? prefixes[-1] : prefix end |
#formatter ⇒ Object
14 15 16 |
# File 'lib/mismatch_inspectable/inspection_options.rb', line 14 def formatter @formatter ||= FormatBuilder.new(format).formatter end |
#to_h ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/mismatch_inspectable/inspection_options.rb', line 18 def to_h { recursive:, include_class:, prefix:, format: } end |
#update_prefix(target_class) ⇒ Object
27 28 29 30 31 |
# File 'lib/mismatch_inspectable/inspection_options.rb', line 27 def update_prefix(target_class) if include_class && comparable_prefix != "#{target_class.class}#" self.prefix = "#{prefix}#{target_class.class}#" end end |