Sha256: afca18f045a0fb0957c4f2dc465b463361fa1995e042d2ba8e0859013ceebed3

Contents?: true

Size: 443 Bytes

Versions: 5

Compression:

Stored size: 443 Bytes

Contents

module ComposedValidations
  class OrStringJoiner
    attr_reader :strings, :last_two
    def initialize(*strings)
      @strings = strings
      @last_two = @strings.pop(2)
    end

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

    private

    def first_elements_string
      strings.join(", ")
    end

    def last_two_elements_string
      last_two.join(" or ")
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
composed_validations-0.0.5 lib/composed_validations/or_string_joiner.rb
composed_validations-0.0.4 lib/composed_validations/or_string_joiner.rb
composed_validations-0.0.3 lib/composed_validations/or_string_joiner.rb
composed_validations-0.0.2 lib/composed_validations/or_string_joiner.rb
composed_validations-0.0.1 lib/composed_validations/or_string_joiner.rb