Class: Mexico::FileSystem::PropertyMap

Inherits:
Object
  • Object
show all
Includes:
ROXML
Defined in:
lib/mexico/file_system/property_map.rb

Overview

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ PropertyMap

Returns a new instance of PropertyMap.



37
38
39
40
41
42
43
44
45
# 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

Instance Attribute Details

#valuesObject

Returns the value of attribute values.



35
36
37
# File 'lib/mexico/file_system/property_map.rb', line 35

def values
  @values
end

Instance Method Details

#[](p_key) ⇒ Object



54
55
56
57
58
59
60
61
62
63
# 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) ⇒ Object



65
66
67
68
69
70
71
72
73
# 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) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
50
51
52
# 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