Class: RubyTDMS::AggregateChannel

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

Instance Method Summary collapse

Constructor Details

#initialize(channels = []) ⇒ AggregateChannel

Returns a new instance of AggregateChannel.



5
6
7
# File 'lib/ruby_tdms/aggregate_channel.rb', line 5

def initialize(channels = [])
  @channels = channels
end

Instance Method Details

#as_jsonObject



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/ruby_tdms/aggregate_channel.rb', line 40

def as_json
  result = @channels[0].as_json
  # Iterate over all channel objects and update properties
  result[:properties] = @channels.reduce({}) do |properties, channel|
    channel.properties.each do |property|
      properties[property.name.to_sym] = property.value
    end
    properties
  end
  result[:values] = values.to_a
  result
end

#data_typeObject



25
26
27
# File 'lib/ruby_tdms/aggregate_channel.rb', line 25

def data_type
  @channels[0].data_type
end

#data_type_idObject



30
31
32
# File 'lib/ruby_tdms/aggregate_channel.rb', line 30

def data_type_id
  @channels[0].data_type_id
end

#inspectObject



10
11
12
# File 'lib/ruby_tdms/aggregate_channel.rb', line 10

def inspect
  "#<#{self.class.name}:#{self.object_id} path=#{path.inspect}, #{@channels.length} channel(s)>"
end

#nameObject



20
21
22
# File 'lib/ruby_tdms/aggregate_channel.rb', line 20

def name
  @channels[0].name
end

#pathObject



15
16
17
# File 'lib/ruby_tdms/aggregate_channel.rb', line 15

def path
  @channels[0].path
end

#valuesObject



35
36
37
# File 'lib/ruby_tdms/aggregate_channel.rb', line 35

def values
  @values ||= AggregateChannelEnumerator.new @channels
end