Module: Extensions::HL7::Segment::InstanceMethods
- Defined in:
- lib/core_ext/segment.rb
Instance Method Summary collapse
Instance Method Details
#[](key) ⇒ Object
13 14 15 |
# File 'lib/core_ext/segment.rb', line 13 def [](key) to_hash[key] end |
#handle_element(key) ⇒ Object
32 33 34 |
# File 'lib/core_ext/segment.rb', line 32 def handle_element(key) self.send(key) end |
#segment_name ⇒ Object
17 18 19 |
# File 'lib/core_ext/segment.rb', line 17 def segment_name self.class.to_s.split("::").last end |
#to_hash ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/core_ext/segment.rb', line 21 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 |