Class: RubyTDMS::Objects::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_tdms/objects/base.rb

Overview

TDMS object base. All objects hold a collection of Segment references since objects can be striped across segments.

Direct Known Subclasses

Channel, File, Group

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, document, segment) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
14
15
16
# File 'lib/ruby_tdms/objects/base.rb', line 9

def initialize(path, document, segment)
	@path = path
	@document = document
	@segment = segment
	@stream = document.stream

	@properties = []
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/ruby_tdms/objects/base.rb', line 6

def path
  @path
end

#propertiesObject (readonly)

Returns the value of attribute properties.



6
7
8
# File 'lib/ruby_tdms/objects/base.rb', line 6

def properties
  @properties
end

#segmentObject (readonly)

Returns the value of attribute segment.



6
7
8
# File 'lib/ruby_tdms/objects/base.rb', line 6

def segment
  @segment
end

#streamObject (readonly)

Returns the value of attribute stream.



6
7
8
# File 'lib/ruby_tdms/objects/base.rb', line 6

def stream
  @stream
end

Instance Method Details

#as_jsonObject



29
30
31
32
33
34
# File 'lib/ruby_tdms/objects/base.rb', line 29

def as_json
	{
		path: path.to_s,
		properties: properties.reduce({}) { |properties, property| properties[property.name.to_s.to_sym] = property.value; properties }
	}
end

#continue_stream(stream, previous_channel) ⇒ Object



19
20
21
# File 'lib/ruby_tdms/objects/base.rb', line 19

def continue_stream(stream, previous_channel)
	parse_properties stream
end

#parse_stream(stream) ⇒ Object



24
25
26
# File 'lib/ruby_tdms/objects/base.rb', line 24

def parse_stream(stream)
	parse_properties stream
end