Class: HQMF::Converter::SimpleRestriction

Inherits:
Object
  • Object
show all
Includes:
HQMF::Conversion::Utilities
Defined in:
lib/hqmf-parser/converter/pass1/simple_restriction.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HQMF::Conversion::Utilities

#build_hash, #check_equality, #json_array, #openstruct_to_json

Constructor Details

#initialize(operator, target, preconditions = []) ⇒ SimpleRestriction

Returns a new instance of SimpleRestriction.



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

def initialize(operator, target, preconditions = [])
  @operator = operator
  @target = target
  @preconditions = preconditions
end

Instance Attribute Details

#convertedObject

Returns the value of attribute converted.



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

def converted
  @converted
end

#generated_data_criteriaObject

Returns the value of attribute generated_data_criteria.



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

def generated_data_criteria
  @generated_data_criteria
end

#negationObject

Returns the value of attribute negation.



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

def negation
  @negation
end

#operatorObject

Returns the value of attribute operator.



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

def operator
  @operator
end

#preconditionsObject

Returns the value of attribute preconditions.



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

def preconditions
  @preconditions
end

#targetObject

Returns the value of attribute target.



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

def target
  @target
end

Class Method Details

.from_json(json) ⇒ Object

Create a new population criteria from a JSON hash keyed off symbols



17
18
19
# File 'lib/hqmf-parser/converter/pass1/simple_restriction.rb', line 17

def self.from_json(json)
  raise "not implemented"
end

Instance Method Details

#comparison?Boolean

Returns:

  • (Boolean)


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

def comparison?
  false
end

#has_preconditions?Boolean

Returns:

  • (Boolean)


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

def has_preconditions?
  preconditions and !preconditions.empty?
end

#klassObject



21
22
23
# File 'lib/hqmf-parser/converter/pass1/simple_restriction.rb', line 21

def klass
  "RESTRICTION"
end

#multi_target?Boolean

Returns:

  • (Boolean)


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

def multi_target?
  has_preconditions?
end

#restriction?Boolean

Returns:

  • (Boolean)


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

def restriction?
  true
end

#restrictionsObject



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

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

#single_target?Boolean

Returns:

  • (Boolean)


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

def single_target?
  !target.nil?
end

#to_jsonObject



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/hqmf-parser/converter/pass1/simple_restriction.rb', line 47

def to_json
  x = nil
  json = {}
  json[:klass] = klass
  json[:operator] = @operator.to_json if @operator
  json[:target] = @target if @target
  json[:negation] = @negation if @negation
  if (@preconditions)
    json[:preconditions] = x if x = json_array(@preconditions)
  end
  json
end