class YAHL7::V2::FieldParser
This class is responsible for parsing the information out of a field.
Attributes
parse_options[RW]
Public Class Methods
new(parse_options)
click to toggle source
# File lib/yahl7/v2/field_parser.rb, line 11 def initialize(parse_options) @parse_options = parse_options end
Public Instance Methods
parse(body)
click to toggle source
# File lib/yahl7/v2/field_parser.rb, line 15 def parse(body) split_fields(body) end
Private Instance Methods
split_body(body, separator)
click to toggle source
# File lib/yahl7/v2/field_parser.rb, line 40 def split_body(body, separator) return '' if body.nil? got = body.split(separator) got.count < 2 ? body : got end
split_components(body)
click to toggle source
# File lib/yahl7/v2/field_parser.rb, line 26 def split_components(body) components = split_body(body, parse_options.component_sep) if components.is_a?(String) split_sub_components(components) else components.map { |c| split_sub_components(c) } end end
split_fields(body)
click to toggle source
# File lib/yahl7/v2/field_parser.rb, line 21 def split_fields(body) parts = split_body(body, parse_options.field_sep) parts.is_a?(Array) ? parts.map { |f| split_components(f) } : split_components(parts) end
split_sub_components(body)
click to toggle source
# File lib/yahl7/v2/field_parser.rb, line 36 def split_sub_components(body) split_body(body, parse_options.sub_component_sep) end