Sha256: d148a6b650a1edf199f2ef192219bad3fc06ea45ad551318428cae4f3c115ce0

Contents?: true

Size: 338 Bytes

Versions: 6

Compression:

Stored size: 338 Bytes

Contents

module StreamBot
  # ArrayPath like XPath, but for Arrays
  class ArrayPath
    
    def self.get_path(object, path)
      # raise "#{object} is not an array" if !object.is_a?(Array) 
      segments = path.chomp.split("/")
      segments.each do |segment|
        object = object[segment]
      end
      object
    end
        
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
streambot-1.0.1 lib/streambot/array_path.rb
streambot-1.0.0 lib/streambot/array_path.rb
streambot-1.0.0.rc4 lib/streambot/array_path.rb
streambot-1.0.0.rc3 lib/streambot/array_path.rb
streambot-1.0.0.rc2 lib/streambot/array_path.rb
streambot-1.0.0.rc1 lib/streambot/array_path.rb