Class: FlexValidations::List Private

Inherits:
Object
  • Object
show all
Defined in:
lib/flex_validations.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(items) ⇒ List

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of List.



20
21
22
# File 'lib/flex_validations.rb', line 20

def initialize(items)
  @items = items
end

Instance Method Details

#to_sObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/flex_validations.rb', line 24

def to_s
  listing = @items.map do |item|
    i = "- #{item}"

    if i.end_with?('.')
      i
    else
      "#{i};"
    end
  end.join("\n")

  if listing.end_with?('.')
    listing
  elsif listing.end_with?(';')
    "#{listing[0..-2]}."
  else
    "#{listing}."
  end
end