module Hippo_eyeDoc::Separator
Attributes
composite_separator[RW]
field_separator[RW]
repetition_separator[RW]
segment_separator[RW]
Public Class Methods
new(options = {})
click to toggle source
# File lib/hippo_eyeDoc/separator.rb, line 10 def initialize(options = {}) [:field_separator, :repetition_separator, :composite_separator, :segment_separator].each do |sym| value = options[sym] || parent_or_default_separator(sym) self.send(:"#{sym}=", value) end end
Public Instance Methods
empty_field_regexp()
click to toggle source
# File lib/hippo_eyeDoc/separator.rb, line 64 def empty_field_regexp %r{([#{regexp_escaped_separators}]) \s+ ([#{regexp_escaped_separators}]) }x end
parent_or_default_separator(separator_type)
click to toggle source
# File lib/hippo_eyeDoc/separator.rb, line 18 def parent_or_default_separator(separator_type) if defined?(parent) && parent parent.send(separator_type.to_sym) else Hippo_eyeDoc.const_get(:"DEFAULT_#{separator_type.to_s.upcase}") end end
parse_separators(input)
click to toggle source
# File lib/hippo_eyeDoc/separator.rb, line 26 def parse_separators(input) if input =~ /\AISA/ @field_separator = input[3,1] @repetition_separator = input[82,1] @composite_separator = input[104,1] @segment_separator = input[105,1] end end
regexp_escaped_separators()
click to toggle source
# File lib/hippo_eyeDoc/separator.rb, line 58 def regexp_escaped_separators Regexp.escape(@composite_separator) + Regexp.escape(@field_separator) + Regexp.escape(@segment_separator) end
remove_empty_fields(input)
click to toggle source
# File lib/hippo_eyeDoc/separator.rb, line 71 def remove_empty_fields(input) while input =~ empty_field_regexp input = input.gsub(empty_field_regexp, '\1\2') end input end
repeating_composite_separator_regexp()
click to toggle source
# File lib/hippo_eyeDoc/separator.rb, line 51 def repeating_composite_separator_regexp %r{ #{Regexp.escape(@composite_separator)}+ #{Regexp.escape(@field_separator)} }x end
repeating_field_separator_at_end_of_segment_regexp()
click to toggle source
# File lib/hippo_eyeDoc/separator.rb, line 44 def repeating_field_separator_at_end_of_segment_regexp %r{ #{Regexp.escape(@field_separator)}+ #{Regexp.escape(@segment_separator)} }x end
separators()
click to toggle source
# File lib/hippo_eyeDoc/separator.rb, line 35 def separators { :field_separator => @field_separator, :composite_separator => @composite_separator, :segment_separator => @segment_separator, :repetition_separator => @repetition_separator } end