def attr(sub, type, at)
return '' if sub.empty?
return '' if type.empty?
return '' if at.empty?
if @@attr_cache.has_key? sub \
and @@attr_cache[sub].has_key? type \
and @@attr_cache[sub][type].has_key? at
return @@attr_cache[sub][type][at].dup
end
unless @@attr_cache.has_key? sub
@@attr_cache[sub] = {}
end
unless @@attr_cache[sub].has_key? type
@@attr_cache[sub][type] = {}
end
at = at.upcase
self[sub].each do |s|
line = ''
if type[0..0] =~ /[0-9]/
line = s if s =~ /\(\s+#{type}\s+(?:[A-Z]|\))/
else
line = s if s =~ /NAME\s+\(?.*'#{type}'.*\)?\s+(?:[A-Z]|\))/
end
multi = ''
case line
when /#{at}\s+[\)A-Z]/
@@attr_cache[sub][type][at] = ['TRUE']
return ['TRUE']
when /#{at}\s+'(.+?)'/
@@attr_cache[sub][type][at] = [$1]
return [$1]
when /#{at}\s+\((.+?)\)/
multi = $1
when /#{at}\s+\(([\w\d\s\.]+)\)/
multi = $1
when /#{at}\s+([\w\d\.]+)/
@@attr_cache[sub][type][at] = [$1]
return [$1]
end
if multi.match(/\$/)
@@attr_cache[sub][type][at] = multi.split("$").collect{|attr| attr.strip}
return @@attr_cache[sub][type][at].dup
elsif not multi.empty?
@@attr_cache[sub][type][at] = multi.gsub(/'/, '').split(' ').collect{|attr| attr.strip}
return @@attr_cache[sub][type][at].dup
end
end
@@attr_cache[sub][type][at] = []
return []
end