Sha256: 111fdf3ce0c44a7dbeefa205ada9fcc5a6b8bff892d3606bcb5b36f56fc620a2

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

module Biro
  module Bvs
    class ScoreResponseBuilder
      def initialize(body)
        @body = build(body)
      end

      def transaction
        @body[0..7]
      end

      def version
        @body[8..9]
      end

      def reserved_applicant
        @body[10..19]
      end

      def reserved_bvs
        @body[20..39]
      end

      def service_code
        @body[40..47]
      end

      def search_type
        @body[48..55]
      end

      def search_version
        @body[56..57]
      end

      def response_type
        @body[58]
      end

      def return_code
        @body[59]
      end

      def search_number
        @body[60..66]
      end

      def response_text_size
        @body[67..70].to_i
      end

      def response_text
        @body[71,response_text_size] || ""
      end

      def response_text_init
        response_text[0..2]
      end

      def response_text_type
        response_text[3..5]
      end

      def response_text_is_present
        response_text[6]
      end

      def response_text_document_type
        response_text[7]
      end

      def response_text_document
        response_text[8..21]
      end

      def response_text_name
        response_text[22..136]
      end

      def response_text_result_score
        response_text[137..140]
      end

      def response_text_description
        response_text[141..160]
      end

      def response_text_over
        response_text[160..500]
      end

      def error_message
        response_text[8..100]
      end

      def build(body)
        body.gsub("\n", '').gsub("\t", '').gsub("\\t", '').gsub("\\n", '').scan(/<PRE>([^<>]*)<\/PRE>/imu).flatten[0]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
biro-0.6.4 lib/biro/gateways/bvs/builders/score_response_builder.rb