Class: HQMF::Converter::SimpleRestriction
- Inherits:
-
Object
- Object
- HQMF::Converter::SimpleRestriction
- Includes:
- HQMF::Conversion::Utilities
- Defined in:
- lib/hqmf-parser/converter/pass1/simple_restriction.rb
Instance Attribute Summary collapse
-
#converted ⇒ Object
Returns the value of attribute converted.
-
#generated_data_criteria ⇒ Object
Returns the value of attribute generated_data_criteria.
-
#negation ⇒ Object
Returns the value of attribute negation.
-
#operator ⇒ Object
Returns the value of attribute operator.
-
#preconditions ⇒ Object
Returns the value of attribute preconditions.
-
#target ⇒ Object
Returns the value of attribute target.
Class Method Summary collapse
-
.from_json(json) ⇒ Object
Create a new population criteria from a JSON hash keyed off symbols.
Instance Method Summary collapse
- #comparison? ⇒ Boolean
- #has_preconditions? ⇒ Boolean
-
#initialize(operator, target, preconditions = []) ⇒ SimpleRestriction
constructor
A new instance of SimpleRestriction.
- #klass ⇒ Object
- #multi_target? ⇒ Boolean
- #restriction? ⇒ Boolean
- #restrictions ⇒ Object
- #single_target? ⇒ Boolean
- #to_json ⇒ Object
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
#converted ⇒ Object
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_criteria ⇒ Object
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 |
#negation ⇒ Object
Returns the value of attribute negation.
9 10 11 |
# File 'lib/hqmf-parser/converter/pass1/simple_restriction.rb', line 9 def negation @negation end |
#operator ⇒ Object
Returns the value of attribute operator.
9 10 11 |
# File 'lib/hqmf-parser/converter/pass1/simple_restriction.rb', line 9 def operator @operator end |
#preconditions ⇒ Object
Returns the value of attribute preconditions.
9 10 11 |
# File 'lib/hqmf-parser/converter/pass1/simple_restriction.rb', line 9 def preconditions @preconditions end |
#target ⇒ Object
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
25 26 27 |
# File 'lib/hqmf-parser/converter/pass1/simple_restriction.rb', line 25 def comparison? false end |
#has_preconditions? ⇒ Boolean
32 33 34 |
# File 'lib/hqmf-parser/converter/pass1/simple_restriction.rb', line 32 def has_preconditions? preconditions and !preconditions.empty? end |
#klass ⇒ Object
21 22 23 |
# File 'lib/hqmf-parser/converter/pass1/simple_restriction.rb', line 21 def klass "RESTRICTION" end |
#multi_target? ⇒ Boolean
39 40 41 |
# File 'lib/hqmf-parser/converter/pass1/simple_restriction.rb', line 39 def multi_target? has_preconditions? end |
#restriction? ⇒ Boolean
28 29 30 |
# File 'lib/hqmf-parser/converter/pass1/simple_restriction.rb', line 28 def restriction? true end |
#restrictions ⇒ Object
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
36 37 38 |
# File 'lib/hqmf-parser/converter/pass1/simple_restriction.rb', line 36 def single_target? !target.nil? end |
#to_json ⇒ Object
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 |