Class: ObjectIdentifier::StringFormatter::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/object_identifier/formatters/string_formatter.rb

Overview

ObjectIdentifier::StringFormatter::Collection formats a collection-specific identification String, which will also necessarily be composed of SingleObject identification Strings.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(objects, parameters) ⇒ Collection

Returns a new instance of Collection.

Parameters:



57
58
59
60
# File 'lib/object_identifier/formatters/string_formatter.rb', line 57

def initialize(objects, parameters)
  @objects = objects
  @parameters = parameters
end

Class Method Details

.call(*args) ⇒ String

Returns the self-identifying String for the passed in object.

Returns:

  • (String)

    the self-identifying String for the passed in object.



50
51
52
# File 'lib/object_identifier/formatters/string_formatter.rb', line 50

def self.call(*args)
  new(*args).call
end

Instance Method Details

#callObject



62
63
64
65
66
67
# File 'lib/object_identifier/formatters/string_formatter.rb', line 62

def call
  output_strings =
    @objects.first(limit).map { |obj| format_single_object(obj) }
  output_strings << "... (#{truncated_objects_count} more)" if truncated?
  output_strings.join(", ")
end