Class: Mexico::FileSystem::Layer
- Inherits:
-
Object
- Object
- Mexico::FileSystem::Layer
- Includes:
- Poseidon, ROXML
- Defined in:
- lib/mexico/file_system/layer.rb
Overview
A layer (or tier) in an transcription or annotation document.
Instance Attribute Summary collapse
-
#document ⇒ Object
Returns the value of attribute document.
Instance Method Summary collapse
- #add_property(prop) ⇒ Object
-
#after_parse ⇒ Object
overrides method in ROXML callback after xml parsing process, to store this element in the document cache.
- #identifier=(new_id) ⇒ Object
-
#initialize(args = {}) ⇒ Layer
constructor
data type content structure.
- #items ⇒ Object
- #items_form_a_forest? ⇒ Boolean
- #items_form_an_edgeless_graph? ⇒ Boolean
-
#predecessor_layers ⇒ Object
returns all layers that are linked to this layer such that this layer is the target, and the result layer is the source.
-
#successor_layers ⇒ Object
returns all layers that are linked to this layer such that this layer is the source, and the result layer is the target.
Constructor Details
#initialize(args = {}) ⇒ Layer
data type content structure
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/mexico/file_system/layer.rb', line 47 def initialize(args={}) args.each do |k,v| if self.respond_to?("#{k}=") send("#{k}=", v) end @properties = Mexico::FileSystem::PropertyMap.new end if properties.nil? properties = ::Mexico::FileSystem::PropertyMap.new(key: 'layerProperties') end end |
Instance Attribute Details
#document ⇒ Object
Returns the value of attribute document.
34 35 36 |
# File 'lib/mexico/file_system/layer.rb', line 34 def document @document end |
Instance Method Details
#add_property(prop) ⇒ Object
102 103 104 |
# File 'lib/mexico/file_system/layer.rb', line 102 def add_property(prop) properties.properties << prop end |
#after_parse ⇒ Object
overrides method in ROXML callback after xml parsing process, to store this element in the document cache.
69 70 71 |
# File 'lib/mexico/file_system/layer.rb', line 69 def after_parse ::Mexico::FileSystem::FiestaDocument.store(self.identifier, self) end |
#identifier=(new_id) ⇒ Object
26 27 28 |
# File 'lib/mexico/file_system/layer.rb', line 26 def identifier=(new_id) @identifier = Mexico::Util::to_xml_id(new_id) end |
#items ⇒ Object
62 63 64 |
# File 'lib/mexico/file_system/layer.rb', line 62 def items @document.items.select{|i| i.layers.include?(self) } end |
#items_form_a_forest? ⇒ Boolean
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/mexico/file_system/layer.rb', line 85 def items_form_a_forest? # I need precise semantics what kinds of item links # are supposed to model an actual parent-child-relationship. self.items.each do |item| puts "sources size for items %s: %i" % [item.identifier, item.sources.size] return false if item.sources.size > 1 end return true end |
#items_form_an_edgeless_graph? ⇒ Boolean
96 97 98 99 100 |
# File 'lib/mexico/file_system/layer.rb', line 96 def items_form_an_edgeless_graph? self.items.each do |item| return false if item.item_links.size > 1 end end |
#predecessor_layers ⇒ Object
returns all layers that are linked to this layer such that this layer is the target, and the result layer is the source.
75 76 77 |
# File 'lib/mexico/file_system/layer.rb', line 75 def predecessor_layers document.layer_connectors.select{|c| c.target==self}.collect{|c| [c.source, c.role]} end |
#successor_layers ⇒ Object
returns all layers that are linked to this layer such that this layer is the source, and the result layer is the target.
81 82 83 |
# File 'lib/mexico/file_system/layer.rb', line 81 def successor_layers document.layer_connectors.select{|c| c.source==self}.collect{|c| [c.target, c.role]} end |