class ObjectIdentifier::StringFormatter
ObjectIdentifier::StringFormatter
builds a String to identify the given object(s).
Constants
- NO_OBJECTS_INDICATOR
-
The String to output when {#objects} is empty.
Public Instance Methods
Source
# 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
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.
@return [String] A string that identifies the object(s).
Private Instance Methods
Source
# File lib/object_identifier/formatters/string_formatter.rb, line 30 def format_collection Collection.new(objects, parameters).call end
Source
# File lib/object_identifier/formatters/string_formatter.rb, line 26 def format_item(object = objects.first) Item.new(object, parameters).call end