class Mexico::FileSystem::PropertyMap

This class provides a corpus representation that is backed up by the filesystem. A central Corpus definition file in the top-level folder contains an XML representation of the corpus structure, and all actual resources are found as files on a file system reachable from the top-level folder.

Attributes

values[RW]

Public Class Methods

new(args={}) click to toggle source
# File lib/mexico/file_system/property_map.rb, line 37
def initialize(args={})
  args.each do |k,v|
    if self.respond_to?("#{k}=")
      send("#{k}=", v)
    end
  end
  @properties = []
  @property_maps = []
end

Public Instance Methods

[](p_key) click to toggle source
# File lib/mexico/file_system/property_map.rb, line 54
def [](p_key)
  # compare_list(p_key)
  if properties.any?{|x| x.key.to_sym == p_key.to_sym}
    return properties.find{|x| x.key.to_sym == p_key.to_sym}
  end
  if property_maps.any?{|x| x.key.to_sym == p_key.to_sym}
    return property_maps.find{|x| x.key.to_sym == p_key.to_sym}
  end
  return nil
end
compare_list(p_key) click to toggle source
# File lib/mexico/file_system/property_map.rb, line 65
def compare_list(p_key)
  puts "    <=>   %s  ::  %s" % %w(ENTRY COMPARE_VAL)
  properties.each do |p|
    puts "    <=>  >%s< :: >%s<  -  %s" % [p.key, p_key, (p.key.to_sym==p_key.to_sym)]
  end
  property_maps.each do |p|
    puts "    <=>  >%s< :: >%s<  -  %s" % [p.key, p_key, (p.key==p_key)]
  end
end
has_key?(p_key) click to toggle source
# File lib/mexico/file_system/property_map.rb, line 47
def has_key?(p_key)
  # compare_list(p_key)
  return true if properties.any?{|x| x.key.to_sym == p_key.to_sym}
  return true if property_maps.any?{|x| x.key.to_sym == p_key.to_sym}
  false
end