Class: HQMF::Converter::SimplePrecondition

Inherits:
Precondition show all
Defined in:
lib/hqmf-parser/converter/pass1/simple_precondition.rb

Constant Summary collapse

COMPARISON =
"COMPARISON"
PRECONDITION =
"PRECONDITION"

Constants inherited from Precondition

Precondition::ALL_FALSE, Precondition::ALL_TRUE, Precondition::AT_LEAST_ONE_FALSE, Precondition::AT_LEAST_ONE_TRUE, Precondition::INVERSIONS, Precondition::NEGATIONS

Instance Attribute Summary collapse

Attributes inherited from Precondition

#comments, #id, #negation, #preconditions, #reference

Instance Method Summary collapse

Methods inherited from Precondition

#conjunction?, #conjunction_code_with_negation, from_json, #referenced_data_criteria

Methods included from HQMF::Conversion::Utilities

#build_hash, #check_equality, #json_array, #openstruct_to_json

Constructor Details

#initialize(id, preconditions, reference, conjunction_code, negation) ⇒ SimplePrecondition

Returns a new instance of SimplePrecondition.



12
13
14
15
16
# File 'lib/hqmf-parser/converter/pass1/simple_precondition.rb', line 12

def initialize(id, preconditions,reference,conjunction_code,negation)
  super(id, preconditions,reference,conjunction_code,negation)
  @id = HQMF::Counter.instance.next if (@id.nil?)
  @klass = PRECONDITION
end

Instance Attribute Details

#conjunction_codeObject

Returns the value of attribute conjunction_code.



10
11
12
# File 'lib/hqmf-parser/converter/pass1/simple_precondition.rb', line 10

def conjunction_code
  @conjunction_code
end

#klassObject

Returns the value of attribute klass.



10
11
12
# File 'lib/hqmf-parser/converter/pass1/simple_precondition.rb', line 10

def klass
  @klass
end

#processedObject

Returns the value of attribute processed.



10
11
12
# File 'lib/hqmf-parser/converter/pass1/simple_precondition.rb', line 10

def processed
  @processed
end

#subset_comparisonObject

Returns the value of attribute subset_comparison.



10
11
12
# File 'lib/hqmf-parser/converter/pass1/simple_precondition.rb', line 10

def subset_comparison
  @subset_comparison
end

Instance Method Details

#comparison?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/hqmf-parser/converter/pass1/simple_precondition.rb', line 24

def comparison?
  @klass == COMPARISON
end

#delete_converted_restrictions!Object



43
44
45
# File 'lib/hqmf-parser/converter/pass1/simple_precondition.rb', line 43

def delete_converted_restrictions!
  preconditions.delete_if {|precondition| precondition.restriction? and precondition.converted}
end

#has_preconditions?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/hqmf-parser/converter/pass1/simple_precondition.rb', line 31

def has_preconditions?
  preconditions and !preconditions.empty?
end

#reference=(reference) ⇒ Object



39
40
41
# File 'lib/hqmf-parser/converter/pass1/simple_precondition.rb', line 39

def reference=(reference)
  @reference = reference
end

#restriction?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/hqmf-parser/converter/pass1/simple_precondition.rb', line 27

def restriction?
  false
end

#restrictionsObject



35
36
37
# File 'lib/hqmf-parser/converter/pass1/simple_precondition.rb', line 35

def restrictions
  preconditions.select {|precondition| precondition.restriction?}
end

#to_jsonObject



18
19
20
21
22
# File 'lib/hqmf-parser/converter/pass1/simple_precondition.rb', line 18

def to_json
  json = super
#        json[:klass] = @klass
  json
end