Class: Group

Inherits:
Array
  • Object
show all
Includes:
Utils
Defined in:
lib/ez7gen/structure_parser.rb

Direct Known Subclasses

OptionalGroup, RepeatingGroup

Constant Summary

Constants included from Utils

Utils::BASE, Utils::BASE_INDICATOR, Utils::DATA_LOOKUP_MIS, Utils::PRIMARY

Instance Method Summary collapse

Methods included from Utils

#blank?, #get_name_without_base, #get_segment_name, #get_type_by_name, #has_html_encoded_ch?, #is_number?, #num_to_nil, #safe_len, #sample_index

Constructor Details

#initialize(*several_variants) ⇒ Group

Returns a new instance of Group.



199
200
201
202
203
204
# File 'lib/ez7gen/structure_parser.rb', line 199

def initialize(*several_variants)
  if(several_variants!= nil && several_variants[0].instance_of?(String))
    several_variants = several_variants[0].split('~').delete_if{|it| it.empty?}
  end
  super(several_variants)
end

Instance Method Details

#resolve(encodedSegments) ⇒ Object



206
207
208
209
210
211
212
213
214
215
216
# File 'lib/ez7gen/structure_parser.rb', line 206

def resolve(encodedSegments)
    # p self
    self.map!{|sub|
      if(sub.kind_of?(Array))
        sub.map!{|it|is_number?(it)? encodedSegments[it.to_i]: it}.flatten
      else
         is_number?(sub)? encodedSegments[sub.to_i]: sub
      end
    }.flatten
  # p self
end

#unwrap(seg) ⇒ Object

unwrap outer parenthesis. this works vs. seg = seg TODO: Refactor?



220
221
222
223
224
# File 'lib/ez7gen/structure_parser.rb', line 220

def unwrap(seg)
  seg[0] = ''
  seg[-1] = ''
  return seg
end