Class: ComposedValidations::AndStringJoiner

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*strings) ⇒ AndStringJoiner

Returns a new instance of AndStringJoiner.



4
5
6
7
# File 'lib/composed_validations/and_string_joiner.rb', line 4

def initialize(*strings)
  @strings = strings
  @last_two = @strings.pop(2)
end

Instance Attribute Details

#last_twoObject (readonly)

Returns the value of attribute last_two.



3
4
5
# File 'lib/composed_validations/and_string_joiner.rb', line 3

def last_two
  @last_two
end

#stringsObject (readonly)

Returns the value of attribute strings.



3
4
5
# File 'lib/composed_validations/and_string_joiner.rb', line 3

def strings
  @strings
end

Instance Method Details

#to_sObject



9
10
11
# File 'lib/composed_validations/and_string_joiner.rb', line 9

def to_s
  [first_elements_string, last_two_elements_string].join(", ").gsub(/^, /,'')
end