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 Item identification Strings.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(objects, parameters) ⇒ Collection

Returns a new instance of Collection.

Parameters:



44
45
46
47
# File 'lib/object_identifier/formatters/string_formatter.rb', line 44

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

Instance Attribute Details

#objectsObject (readonly)

Returns the value of attribute objects.



38
39
40
# File 'lib/object_identifier/formatters/string_formatter.rb', line 38

def objects
  @objects
end

#parametersObject (readonly)

Returns the value of attribute parameters.



38
39
40
# File 'lib/object_identifier/formatters/string_formatter.rb', line 38

def parameters
  @parameters
end

Instance Method Details

#callString

Build a comma-separated list of formatted item Strings representing the given objects.

Returns:

  • (String)


53
54
55
56
57
# File 'lib/object_identifier/formatters/string_formatter.rb', line 53

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