Class: FHIR::Field

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = '') ⇒ Field

Returns a new instance of Field.



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

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.



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

def binding
  @binding
end

#constraintObject

Returns the value of attribute constraint.



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

def constraint
  @constraint
end

#local_nameObject

Returns the value of attribute local_name.



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

def local_name
  @local_name
end

#maxObject

Returns the value of attribute max.



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

def max
  @max
end

#minObject

Returns the value of attribute min.



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

def min
  @min
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

#regexObject

Returns the value of attribute regex.



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

def regex
  @regex
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

#type_profilesObject

Returns the value of attribute type_profiles.



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

def type_profiles
  @type_profiles
end

#valid_codesObject

Returns the value of attribute valid_codes.



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

def valid_codes
  @valid_codes
end

Instance Method Details

#fix_name(name) ⇒ Object



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

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

#serializeObject



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

def serialize
  hash = Hash.new
  self.instance_variables.each do |v|
    hash[v.to_s[1..-1]] = self.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