Created
May 31, 2011 19:19
-
-
Save jcalvert/1001100 to your computer and use it in GitHub Desktop.
BAMF Row object Monkeypatch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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