Class: ObjectIdentifier::StringFormatter
- Inherits:
-
BaseFormatter
- Object
- BaseFormatter
- 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, Item
Constant Summary collapse
- NO_OBJECTS_INDICATOR =
The String to output when BaseFormatter#objects is empty.
"[no objects]"
Instance Attribute Summary
Attributes inherited from BaseFormatter
Instance Method Summary collapse
-
#call ⇒ String
Output the self-identifying string for the given object(s).
Methods inherited from BaseFormatter
Constructor Details
This class inherits a constructor from ObjectIdentifier::BaseFormatter
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.
14 15 16 17 18 19 20 21 22 |
# File 'lib/object_identifier/formatters/string_formatter.rb', line 14 def call if objects.none? NO_OBJECTS_INDICATOR elsif objects.one? format_item else # objects.size > 1 format_collection end end |