Class: RubyTDMS::Document
- Inherits:
-
Object
- Object
- RubyTDMS::Document
- Defined in:
- lib/ruby_tdms/document.rb
Instance Attribute Summary collapse
-
#segments ⇒ Object
readonly
attr_reader :segments, :channels, :file.
-
#stream ⇒ Object
readonly
attr_reader :segments, :channels, :file.
Instance Method Summary collapse
-
#as_json ⇒ Object
Returns a hash representation of the entire TDMS document, looking vaguely like: { file : [ properties: {} ], groups : [ { path: ‘/Time Domain’, properties: {}.
- #channels ⇒ Object
- #groups ⇒ Object
-
#initialize(stream) ⇒ Document
constructor
A new instance of Document.
- #objects ⇒ Object
-
#raw_channels ⇒ Array<TDMS::Objects::Channel>
The un-aggregated channel objects in the current document.
Constructor Details
#initialize(stream) ⇒ Document
Returns a new instance of Document.
11 12 13 14 15 16 17 18 |
# File 'lib/ruby_tdms/document.rb', line 11 def initialize(stream) @channel_aggregates = [] @segments = [] @stream = stream parse_segments build_aggregates end |
Instance Attribute Details
#segments ⇒ Object (readonly)
attr_reader :segments, :channels, :file
8 9 10 |
# File 'lib/ruby_tdms/document.rb', line 8 def segments @segments end |
#stream ⇒ Object (readonly)
attr_reader :segments, :channels, :file
8 9 10 |
# File 'lib/ruby_tdms/document.rb', line 8 def stream @stream end |
Instance Method Details
#as_json ⇒ Object
Returns a hash representation of the entire TDMS document, looking vaguely like: { file : [ properties: {} ], groups : [ { path: ‘/Time Domain’, properties: {}
} ], channels : [ { path: ‘/Time Domain/Current Phase A’, name: ‘Current Phase A’, properties: { ‘wf_start’: 2015-05-23 05:22:22 }, values: [ 1, 2, 3, 4, 5 ] } ] }
69 70 71 72 73 74 75 |
# File 'lib/ruby_tdms/document.rb', line 69 def as_json { file: objects.find { |object| object.is_a? Objects::File }.as_json, groups: objects.select { |object| object.is_a? Objects::Group }.map(&:as_json), channels: channels.map(&:as_json) } end |
#channels ⇒ Object
21 22 23 |
# File 'lib/ruby_tdms/document.rb', line 21 def channels @channel_aggregates end |
#groups ⇒ Object
26 27 28 |
# File 'lib/ruby_tdms/document.rb', line 26 def groups objects.select { |object| object.is_a? Objects::Group } end |
#objects ⇒ Object
31 32 33 |
# File 'lib/ruby_tdms/document.rb', line 31 def objects segments.flat_map { |segment| segment.objects } end |
#raw_channels ⇒ Array<TDMS::Objects::Channel>
Returns The un-aggregated channel objects in the current document.
37 38 39 |
# File 'lib/ruby_tdms/document.rb', line 37 def raw_channels objects.select { |object| object.is_a? Objects::Channel } end |