Skip to content

Instantly share code, notes, and snippets.

@jcalvert
Created May 31, 2011 19:19
Show Gist options
  • Save jcalvert/1001100 to your computer and use it in GitHub Desktop.
Save jcalvert/1001100 to your computer and use it in GitHub Desktop.
BAMF Row object Monkeypatch
class BAMFCSV::Table::Row
def [](key)
field_key=@header_map[key]
if(!field_key.nil?)
@fields[field_key]
end
end
def []=(key,value)
if(self[key].nil?)
@header_map[key] = @header_map.values.last+1
@fields<<value
else
@fields[@header_map[key]]=value
end
end
def to_h
Hash[@header_map.keys.zip(@fields)]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment