Module: Extensions::HL7::Segment::InstanceMethods

Defined in:
lib/core_ext/segment.rb

Instance Method Summary collapse

Instance Method Details

#handle_element(key) ⇒ Object



28
29
30
# File 'lib/core_ext/segment.rb', line 28

def handle_element(key)
  self.send(key)
end

#segment_nameObject



13
14
15
# File 'lib/core_ext/segment.rb', line 13

def segment_name
  self.class.to_s.split("::").last
end

#to_hashObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/core_ext/segment.rb', line 17

def to_hash
  @hash ||= {}
  fields = self.class.fields
  if fields.is_a?Hash
    self.class.fields.keys.each do |key|
      @hash[key.to_s.camelize(:lower)] = self.handle_element(key)
    end
  end
  @hash
end