class RubyTDMS::Path
Constants
- PATH_MATCHER
- RAW_MATCHER
Public Class Methods
new(options = {})
click to toggle source
Can initialize with parts, path, or raw. Elements can contain / only in raw or parts forms.
# File lib/ruby_tdms/path.rb, line 7 def initialize(options = {}) raise ArgumentError, 'Initialize with at most one of +parts+, +path+, or +raw+.' if options.length > 1 @parts = options[:parts] || [] self.path = options[:path] if options.has_key? :path self.raw = options[:raw] if options.has_key? :raw end
Public Instance Methods
==(other)
click to toggle source
Calls superclass method
# File lib/ruby_tdms/path.rb, line 65 def ==(other) if other.is_a? String self.to_s == other elsif other.is_a? self.class self.dump == other.dump else super end end
Also aliased as: eql?
dump()
click to toggle source
# File lib/ruby_tdms/path.rb, line 15 def dump to_s end
hash()
click to toggle source
# File lib/ruby_tdms/path.rb, line 20 def hash to_s.hash end
inspect()
click to toggle source
# File lib/ruby_tdms/path.rb, line 25 def inspect "#<#{self.class.name}:#{self.object_id} path=#{path.inspect}>" end
load(string)
click to toggle source
# File lib/ruby_tdms/path.rb, line 30 def load(string) self.path = string end
path()
click to toggle source
# File lib/ruby_tdms/path.rb, line 35 def path '/' + @parts.map { |part| part.gsub('/', '\/') }.join('/') end
path=(value)
click to toggle source
# File lib/ruby_tdms/path.rb, line 40 def path=(value) @parts = value._?('').split(PATH_MATCHER).reject { |x| x.length == 0 }.map { |part| decode_part part } end
raw()
click to toggle source
# File lib/ruby_tdms/path.rb, line 45 def raw '/' + @parts.map { |part| encode_part part }.join('/') end
raw=(value)
click to toggle source
# File lib/ruby_tdms/path.rb, line 50 def raw=(value) @parts = value._?('').split(RAW_MATCHER).reject { |x| x.length == 0 }.map { |part| decode_raw_part part } end
to_a()
click to toggle source
# File lib/ruby_tdms/path.rb, line 55 def to_a @parts end
to_s()
click to toggle source
# File lib/ruby_tdms/path.rb, line 60 def to_s path end
Protected Instance Methods
decode_part(part)
click to toggle source
# File lib/ruby_tdms/path.rb, line 81 def decode_part(part) part.gsub(/\\\//, '/') end
decode_raw_part(part)
click to toggle source
# File lib/ruby_tdms/path.rb, line 86 def decode_raw_part(part) part.gsub(/(^'|'$)/, '').gsub(/''/, "'") end
encode_part(part)
click to toggle source
Pure part representation -> raw encoded representation “my / part's / awesomeness” -> “'my / part''s / awesomeness'”
# File lib/ruby_tdms/path.rb, line 93 def encode_part(part) "'#{part.gsub(/'/, "''")}'" end