lib/rbbt/util/tsv/accessor.rb in rbbt-util-3.2.0 vs lib/rbbt/util/tsv/accessor.rb in rbbt-util-3.2.1
- old
+ new
@@ -1,12 +1,12 @@
require 'rbbt/util/resource'
require 'rbbt/util/misc'
class TSV
## Make sure we overwrite the methods declared by attr_accessor
- MAIN_ACCESSORS = :data, :key_field, :fields, :cast
- EXTRA_ACCESSORS = :filename, :identifiers, :namespace, :datadir, :type, :case_insensitive
+ MAIN_ACCESSORS = :data, :key_field, :fields, :cast
+ EXTRA_ACCESSORS = :filename, :identifiers, :namespace, :type, :case_insensitive
attr_accessor *(MAIN_ACCESSORS + EXTRA_ACCESSORS)
def self.zip_fields(list, fields = nil)
return [] if list.nil? || list.empty?
fields ||= list.fields if list.respond_to? :fields
@@ -31,11 +31,11 @@
namespace_str
end
def fullname
return self if self =~ /:/ or namespace.nil?
- namespace + ":" << self
+ namespace.to_s + ":" << self
end
def ==(string)
return false unless String === string
return true if self.casecmp(string) == 0
@@ -141,12 +141,12 @@
end
def fields=(new_fields)
new_fields.collect! do |field|
if Field === field
- if field !~ /:/ and field.namespace != nil and field.namespace != namespace
- field.namespace + ":" + field.to_s
+ if field !~ /:/ and field.namespace != nil and field.namespace.to_s != namespace.to_s
+ field.namespace.to_s + ":" + field.to_s
else
field
end
else
field
@@ -284,10 +284,12 @@
str << "#: " << Misc.hash2string(EXTRA_ACCESSORS.collect{|key| [key, self.send(key)]}) << "\n" unless no_options
if fields
str << "#" << key_field << "\t" << fields * "\t" << "\n"
end
+ saved_unnamed = unnamed
+ unnamed = false
if keys.nil?
each do |key, values|
key = key.to_s if Symbol === key
str << key.dup << values_to_s(values)
end
@@ -296,9 +298,10 @@
key = key.to_s if Symbol === key
str << key.dup << values_to_s(values)
end
end
+ unnamed = saved_unnamed
str
end
def value_peek
peek = {}