Class: C0::Table
Overview
A tabular group: name, headers, and records.
Instance Method Summary collapse
- #each ⇒ Object
- #header_count ⇒ Object
- #headers ⇒ Object
-
#initialize(buf, offset = 0) ⇒ Table
constructor
A new instance of Table.
- #name ⇒ Object
- #record(index) ⇒ Object
- #record_count ⇒ Object
- #records ⇒ Object
- #size ⇒ Object
Constructor Details
Instance Method Details
#each ⇒ Object
156 157 158 159 160 |
# File 'lib/c0.rb', line 156 def each return enum_for(:each) unless block_given? @records.each { |s, e| yield Record.new(@buf, s, e) } end |
#header_count ⇒ Object
143 |
# File 'lib/c0.rb', line 143 def header_count = @headers.size |
#headers ⇒ Object
141 |
# File 'lib/c0.rb', line 141 def headers = @headers.map { |s, e| @buf.byteslice(s, e - s) } |
#name ⇒ Object
139 |
# File 'lib/c0.rb', line 139 def name = @buf.byteslice(@name[0], @name[1] - @name[0]) |
#record(index) ⇒ Object
147 148 149 150 |
# File 'lib/c0.rb', line 147 def record(index) s, e = @records[index] Record.new(@buf, s, e) end |
#record_count ⇒ Object
145 |
# File 'lib/c0.rb', line 145 def record_count = @records.size |
#records ⇒ Object
152 |
# File 'lib/c0.rb', line 152 def records = (0...@records.size).map { |i| record(i) } |
#size ⇒ Object
154 |
# File 'lib/c0.rb', line 154 def size = @records.size |