Class: SimpleHL7::Subcomponent
- Inherits:
-
Object
- Object
- SimpleHL7::Subcomponent
- Defined in:
- lib/simple_hl7/subcomponent.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(value) ⇒ Subcomponent
constructor
A new instance of Subcomponent.
- #to_hl7(separator_chars) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(value) ⇒ Subcomponent
Returns a new instance of Subcomponent.
5 6 7 |
# File 'lib/simple_hl7/subcomponent.rb', line 5 def initialize(value) @value = value.nil? ? '' : value end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
3 4 5 |
# File 'lib/simple_hl7/subcomponent.rb', line 3 def value @value end |
Class Method Details
.parse(str, separator_chars) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/simple_hl7/subcomponent.rb', line 26 def self.parse(str, separator_chars) value = str if value.respond_to? :gsub! value.gsub!("\\E\\", separator_chars.escape) value.gsub!("\\F\\", separator_chars.field) value.gsub!("\\R\\", separator_chars.repetition) value.gsub!("\\S\\", separator_chars.component) value.gsub!("\\T\\", separator_chars.subcomponent) end Subcomponent.new(value) rescue => e raise e, "Encountered exception parsing message: #{e}", e.backtrace end |
Instance Method Details
#to_hl7(separator_chars) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/simple_hl7/subcomponent.rb', line 9 def to_hl7(separator_chars) if value.respond_to? :gsub! hl7 = value.gsub(separator_chars.escape, "\\E\\") hl7.gsub!(separator_chars.field, "\\F\\") hl7.gsub!(separator_chars.repetition, "\\R\\") hl7.gsub!(separator_chars.component, "\\S\\") hl7.gsub!(separator_chars.subcomponent, "\\T\\") end hl7 rescue => e raise e, "Encountered exception building message: #{e}", e.backtrace end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/simple_hl7/subcomponent.rb', line 22 def to_s value end |