bamfcsv 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bamfcsv (0.1.1)
4
+ bamfcsv (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/lib/bamfcsv/table.rb CHANGED
@@ -36,13 +36,19 @@ module BAMFCSV
36
36
  end
37
37
 
38
38
  class Row
39
- def initialize(header_map, values)
39
+ attr_reader :fields
40
+
41
+ def initialize(header_map, fields)
40
42
  @header_map = header_map
41
- @values = values
43
+ @fields = fields
44
+ end
45
+
46
+ def headers
47
+ @header_map.keys
42
48
  end
43
49
 
44
50
  def [](key)
45
- @values[@header_map[key]]
51
+ @fields[@header_map[key]]
46
52
  end
47
53
  end
48
54
  end
@@ -1,3 +1,3 @@
1
1
  module BAMFCSV
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -155,6 +155,18 @@ describe BAMFCSV do
155
155
  table.first["a"].should == "1"
156
156
  table[1]["c"].should == "z"
157
157
  end
158
+
159
+ it "knows the headers" do
160
+ table = BAMFCSV.parse("a,b,c\r\n1,2,3\r\nx,y,z", :headers => true)
161
+ row = table.first
162
+ row.headers.should == ['a', 'b', 'c']
163
+ end
164
+
165
+ it "knows the fields" do
166
+ table = BAMFCSV.parse("a,b,c\r\n1,2,3\r\nx,y,z", :headers => true)
167
+ row = table.first
168
+ row.fields.should == ['1', '2', '3']
169
+ end
158
170
  end
159
171
 
160
172
  describe "Table#each" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: bamfcsv
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.2
5
+ version: 0.1.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jon Distad
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-04-08 00:00:00 -04:00
14
+ date: 2011-04-15 00:00:00 -04:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency