Class: FHIR::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/fhir_models/bootstrap/field.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = '') ⇒ Field

Returns a new instance of Field.



15
16
17
18
19
20
# File 'lib/fhir_models/bootstrap/field.rb', line 15

def initialize(name = '')
  @name = name
  @local_name = fix_name(@name)
  @type_profiles = []
  @valid_codes = []
end

Instance Attribute Details

#bindingObject

Returns the value of attribute binding.



11
12
13
# File 'lib/fhir_models/bootstrap/field.rb', line 11

def binding
  @binding
end

#constraintObject

Returns the value of attribute constraint.



13
14
15
# File 'lib/fhir_models/bootstrap/field.rb', line 13

def constraint
  @constraint
end

#local_nameObject

Returns the value of attribute local_name.



4
5
6
# File 'lib/fhir_models/bootstrap/field.rb', line 4

def local_name
  @local_name
end

#maxObject

Returns the value of attribute max.



9
10
11
# File 'lib/fhir_models/bootstrap/field.rb', line 9

def max
  @max
end

#minObject

Returns the value of attribute min.



8
9
10
# File 'lib/fhir_models/bootstrap/field.rb', line 8

def min
  @min
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/fhir_models/bootstrap/field.rb', line 3

def name
  @name
end

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/fhir_models/bootstrap/field.rb', line 5

def path
  @path
end

#regexObject

Returns the value of attribute regex.



12
13
14
# File 'lib/fhir_models/bootstrap/field.rb', line 12

def regex
  @regex
end

#typeObject

Returns the value of attribute type.



6
7
8
# File 'lib/fhir_models/bootstrap/field.rb', line 6

def type
  @type
end

#type_profilesObject

Returns the value of attribute type_profiles.



7
8
9
# File 'lib/fhir_models/bootstrap/field.rb', line 7

def type_profiles
  @type_profiles
end

#valid_codesObject

Returns the value of attribute valid_codes.



10
11
12
# File 'lib/fhir_models/bootstrap/field.rb', line 10

def valid_codes
  @valid_codes
end

Instance Method Details

#fix_name(name) ⇒ Object



37
38
39
40
41
# File 'lib/fhir_models/bootstrap/field.rb', line 37

def fix_name(name)
  fix = nil
  fix = "local_#{name}" if %w[class method resourceType].include?(name)
  fix
end

#serializeObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fhir_models/bootstrap/field.rb', line 22

def serialize
  hash = {}
  instance_variables.each do |v|
    hash[v.to_s[1..-1]] = instance_variable_get(v)
  end
  hash.delete('name')
  hash.keep_if do |_key, value|
    !value.nil? && ((value.is_a?(Hash) && !value.empty?) ||
                      (value.is_a?(Array) && !value.empty?) ||
                      (!value.is_a?(Hash) && !value.is_a?(Array))
                   )
  end
  hash
end