Sha256: 524fca902330a38866ac0647388f0efc4c0de750921ade6c8a17e475cc2b2a96

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

require 'ncs_navigator/mdes'

module NcsNavigator::Mdes
  ##
  # One dispostion code in the MDES.
  class DispositionCode

    attr_accessor :event
    attr_accessor :final_category
    attr_accessor :sub_category
    attr_accessor :disposition
    attr_accessor :category_code
    attr_accessor :interim_code
    attr_accessor :final_code

    ##
    # Given attributes (presumably loaded from a YAML file) create
    # a new instance of a DispositionCode
    # 
    # @return [DispositionCode] the created instance.
    def initialize(attrs)
      %w(event final_category sub_category disposition category_code interim_code final_code).each do |a|
        self.send("#{a}=", attrs[a])
      end
    end

    ##
    # If the code's final category signifies successful completion, returns
    # true; otherwise, returns false.
    #
    # @return [Boolean]
    def success?
      final_category.to_s.start_with?('Complete')
    end

    ##
    # Provides a briefer inspection for cleaner IRB use.
    #
    # @return [String]
    def inspect
      "\#<#{self.class} event=#{event.inspect} disposition=#{disposition.inspect} status_code=#{interim_code.inspect}/#{final_code.inspect}>"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ncs_mdes-0.10.0 lib/ncs_navigator/mdes/disposition_code.rb
ncs_mdes-0.9.0 lib/ncs_navigator/mdes/disposition_code.rb
ncs_mdes-0.8.1 lib/ncs_navigator/mdes/disposition_code.rb
ncs_mdes-0.8.0 lib/ncs_navigator/mdes/disposition_code.rb