class Tdms::Path

Attributes

channel[R]
group[R]

Public Class Methods

new(options={}) click to toggle source
# File lib/tdms/path.rb, line 6
def initialize(options={})
  load(options[:path]) if options[:path]
  @group   = options[:group]   if options[:group]
  @channel = options[:channel] if options[:channel]
end

Public Instance Methods

==(other) click to toggle source
Calls superclass method
# File lib/tdms/path.rb, line 20
def ==(other)
  if other.is_a?(String)
    self.to_s == other
  elsif other.is_a?(Path)
    self.dump == other.dump
  else
    super
  end
end
channel?() click to toggle source
# File lib/tdms/path.rb, line 53
def channel?
  (! @channel.nil?)
end
dump() click to toggle source
# File lib/tdms/path.rb, line 30
def dump
  raise ArgumentError if channel && group.nil?

  parts = [""]
  parts << ("'" + group.sub("'","''")   + "'") if group
  parts << ("'" + channel.sub("'","''") + "'") if channel

  dumped = parts.join("/")
  dumped.empty? ? "/" : dumped
end
group?() click to toggle source
# File lib/tdms/path.rb, line 49
def group?
  (! @group.nil?) && (@channel.nil?)
end
load(path) click to toggle source
# File lib/tdms/path.rb, line 12
def load(path)
  segments = path.split("/").map do |seg|
    seg.sub(/^'/,'').sub(/'$/,'').sub("''", "'")
  end

  _, @group, @channel = *segments
end
root?() click to toggle source
# File lib/tdms/path.rb, line 45
def root?
  (! channel?) && (! group?)
end
to_s() click to toggle source
# File lib/tdms/path.rb, line 41
def to_s
  dump
end