Sha256: 9deb2b3d04ed40711e6f5760b89c12f54e8f682957e1231b65a564fc86bf257a

Contents?: true

Size: 1.34 KB

Versions: 7

Compression:

Stored size: 1.34 KB

Contents

module HQMF
  
  module Converter
  
    class SimplePrecondition < HQMF::Precondition

      COMPARISON = "COMPARISON"
      PRECONDITION = "PRECONDITION"

      attr_accessor :klass, :processed, :subset_comparison

      def initialize(id, preconditions,reference,conjunction_code,negation)
        super(id, preconditions,reference,conjunction_code,negation)
        @id = @@ids.next if (@id.nil?)
        @klass = PRECONDITION
      end
      
      def to_json
        json = super
#        json[:klass] = @klass
        json
      end
      
      def comparison?
        @klass == COMPARISON
      end
      def restriction?
        false
      end
      
      def has_preconditions?
        preconditions and !preconditions.empty?
      end
      
      def restrictions
        preconditions.select {|precondition| precondition.restriction?}
      end
      
      def reference=(reference)
        @reference = reference
      end
      
      def delete_converted_restrictions!
        preconditions.delete_if {|precondition| precondition.restriction? and precondition.converted}
      end
      
      # Simple class to issue monotonically increasing integer identifiers
      class Counter
        def initialize
          @count = 0
        end

        def next
          @count+=1
        end
      end
      @@ids = Counter.new
    
    end
  end
  
  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hqmf-parser-1.0.6 lib/hqmf-parser/converter/pass1/simple_precondition.rb
hqmf-parser-1.0.5 lib/hqmf-parser/converter/pass1/simple_precondition.rb
hqmf-parser-1.0.4 lib/hqmf-parser/converter/pass1/simple_precondition.rb
hqmf-parser-1.0.3 lib/hqmf-parser/converter/pass1/simple_precondition.rb
hqmf-parser-1.0.2 lib/hqmf-parser/converter/pass1/simple_precondition.rb
hqmf-parser-1.0.1 lib/hqmf-parser/converter/pass1/simple_precondition.rb
hqmf-parser-1.0.0 lib/hqmf-parser/converter/pass1/simple_precondition.rb