Class: ObjectIdentifier::StringFormatter::Collection
- 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
-
#objects ⇒ Object
readonly
Returns the value of attribute objects.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
Instance Method Summary collapse
-
#call ⇒ String
Build a comma-separated list of formatted item Strings representing the given objects.
-
#initialize(objects, parameters) ⇒ Collection
constructor
A new instance of Collection.
Constructor Details
#initialize(objects, parameters) ⇒ Collection
Returns a new instance of Collection.
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
#objects ⇒ Object (readonly)
Returns the value of attribute objects.
38 39 40 |
# File 'lib/object_identifier/formatters/string_formatter.rb', line 38 def objects @objects end |
#parameters ⇒ Object (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
#call ⇒ String
Build a comma-separated list of formatted item Strings representing the given objects.
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 |