Class: Mexico::FileSystem::Section

Inherits:
Object
  • Object
show all
Includes:
ROXML
Defined in:
lib/mexico/file_system/section.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.

Constant Summary collapse

LIFECYCLE =
'lifecycle'
VOCABULARIES =
'vocabularies'
LAYER_TYPES =
'layerTypes'
MEDIA_CONTEXT =
'mediaContext'
DATA_MODEL =
'dataModel'
SECTION_KEYS =
[LIFECYCLE, VOCABULARIES, LAYER_TYPES, MEDIA_CONTEXT, DATA_MODEL]

Instance Method Summary collapse

Constructor Details

#initialize(key = 'NOTGIVEN') ⇒ Section

Returns a new instance of Section.


43
44
45
46
47
# File 'lib/mexico/file_system/section.rb', line 43

def initialize(key='NOTGIVEN')
  @key = key
  @properties = []
  @property_maps = []
end

Instance Method Details

#[](p_key) ⇒ Object


56
57
58
59
60
61
62
63
64
65
# File 'lib/mexico/file_system/section.rb', line 56

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

#has_key?(p_key) ⇒ Boolean

Returns:

  • (Boolean)

49
50
51
52
53
54
# File 'lib/mexico/file_system/section.rb', line 49

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