Class: Delphin::ProfileTable
- Inherits:
-
Object
- Object
- Delphin::ProfileTable
- Includes:
- Enumerable
- Defined in:
- lib/delphin.rb
Overview
A data table in a TSDB profile.
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#profile ⇒ Object
readonly
Returns the value of attribute profile.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Instance Method Summary collapse
-
#each ⇒ Object
Enumerate the records in this table.
-
#initialize(profile, name, schema) ⇒ ProfileTable
constructor
A new instance of ProfileTable.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(profile, name, schema) ⇒ ProfileTable
Returns a new instance of ProfileTable.
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/delphin.rb', line 236 def initialize(profile, name, schema) @profile = profile @name = name @schema = schema # Find the table containing this table. It may be gzipped. filename = File.join(profile.directory, name) gzname = filename + ".gz" if File.exist?(filename) @filename = filename @file = open(filename) elsif File.exist?(gzname) @filename = gzname @file = Zlib::GzipReader.open(gzname) else raise MissingDataFile.new(@name, @profile) end end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
234 235 236 |
# File 'lib/delphin.rb', line 234 def filename @filename end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
234 235 236 |
# File 'lib/delphin.rb', line 234 def name @name end |
#profile ⇒ Object (readonly)
Returns the value of attribute profile.
234 235 236 |
# File 'lib/delphin.rb', line 234 def profile @profile end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
234 235 236 |
# File 'lib/delphin.rb', line 234 def schema @schema end |
Instance Method Details
#each ⇒ Object
Enumerate the records in this table.
263 264 265 266 267 |
# File 'lib/delphin.rb', line 263 def each @file.each do |line| yield @schema.record(line.strip!) end end |
#inspect ⇒ Object
254 255 256 |
# File 'lib/delphin.rb', line 254 def inspect "#{self.class}(#{name}) in #{profile}" end |
#to_s ⇒ Object
258 259 260 |
# File 'lib/delphin.rb', line 258 def to_s inspect end |