Sha256: 578505ef5cb052c19d28ed92345269a441d3fd4e3f751abe9f7da1485192c843

Contents?: true

Size: 1.06 KB

Versions: 12

Compression:

Stored size: 1.06 KB

Contents

module Eddy
  module Util
    # @!group Normalize

    # See: [Trailing delimiters and 999 response - X12 RFI](http://www.x12.org/rfis/Trailing%20delimiters%20and%20999%20response.pdf)
    #
    # @param itch [String] String containing an EDI Interchange.
    # @param element_separator [String] ("\*")
    # @param segment_separator [String] ("~")
    # @return [String]
    def self.trim_delims_from_interchange(itch, element_separator: "*", segment_separator: "~")
      e_sep = Regexp.escape(element_separator)
      s_sep = Regexp.escape(segment_separator)
      return itch.gsub(/#{e_sep}+(?=#{s_sep})/, "")
    end

    # See: [Trailing delimiters and 999 response - X12 RFI](http://www.x12.org/rfis/Trailing%20delimiters%20and%20999%20response.pdf)
    #
    # @param segment [String] String containing an EDI segment.
    # @param separator [String] ("\*")
    # @return [String]
    def self.trim_delims_from_segment(segment, separator: "*")
      e_sep = Regexp.escape(separator)
      return segment.gsub(/#{e_sep}+(?=$)/, "")
    end

    # @!endgroup Normalize
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
eddy-0.10.0 lib/eddy/util/trim.rb
eddy-0.9.2 lib/eddy/util/trim.rb
eddy-0.9.1 lib/eddy/util/trim.rb
eddy-0.9.0 lib/eddy/util/trim.rb
eddy-0.8.4 lib/eddy/util/trim.rb
eddy-0.8.3 lib/eddy/util/trim.rb
eddy-0.8.2 lib/eddy/util/trim.rb
eddy-0.8.1 lib/eddy/util/trim.rb
eddy-0.8.0 lib/eddy/util/trim.rb
eddy-0.7.0 lib/eddy/util/trim.rb
eddy-0.6.0 lib/eddy/util/trim.rb
eddy-0.5.1 lib/eddy/util/trim.rb