Class: ObjectIdentifier::StringFormatter
- Defined in:
- lib/object_identifier/formatters/string_formatter.rb
Overview
ObjectIdentifier::StringFormatter builds a String to identify the given object(s).
Defined Under Namespace
Classes: Collection, SingleObject
Constant Summary collapse
- NO_OBJECTS_INDICATOR =
"[no objects]"
Class Method Summary collapse
Instance Method Summary collapse
-
#call ⇒ String
Output the self-identifying string for the given object(s).
-
#initialize(objects, parameters = ObjectIdentifier.buid_parameters) ⇒ StringFormatter
constructor
A new instance of StringFormatter.
Constructor Details
#initialize(objects, parameters = ObjectIdentifier.buid_parameters) ⇒ StringFormatter
Returns a new instance of StringFormatter.
15 16 17 18 |
# File 'lib/object_identifier/formatters/string_formatter.rb', line 15 def initialize(objects, parameters = ObjectIdentifier.buid_parameters) @objects = ObjectIdentifier::ArrayWrap.(objects) @parameters = parameters end |
Class Method Details
.call(objects, parameters = ObjectIdentifier.buid_parameters) ⇒ Object
8 9 10 |
# File 'lib/object_identifier/formatters/string_formatter.rb', line 8 def self.call(objects, parameters = ObjectIdentifier.buid_parameters) new(objects, parameters).call end |
Instance Method Details
#call ⇒ String
Output the self-identifying string for the given object(s). Will either return a single object representation or a list of object representations, based on the number of objects we’re identifying.
25 26 27 28 29 30 31 32 33 |
# File 'lib/object_identifier/formatters/string_formatter.rb', line 25 def call if @objects.none? NO_OBJECTS_INDICATOR elsif @objects.one? format_single_object else # @objects.size > 1 format_multiple_objects end end |