Class: Mexico::FileSystem::Layer

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Layer

data type content structure



40
41
42
43
44
45
46
# File 'lib/mexico/file_system/layer.rb', line 40

def initialize(args={})
  args.each do |k,v|
    if self.respond_to?("#{k}=")
      send("#{k}=", v)
    end
  end
end

Instance Attribute Details

#documentObject

Returns the value of attribute document.



27
28
29
# File 'lib/mexico/file_system/layer.rb', line 27

def document
  @document
end

Instance Method Details

#after_parseObject

overrides method in ROXML callback after xml parsing process, to store this element in the document cache.



55
56
57
# File 'lib/mexico/file_system/layer.rb', line 55

def after_parse
  ::Mexico::FileSystem::FiestaDocument.store(self.identifier, self)
end

#itemsObject



48
49
50
# File 'lib/mexico/file_system/layer.rb', line 48

def items
  @document.items.select{|i| i.layers.include?(self) }
end

#items_form_a_forest?Boolean

Returns:

  • (Boolean)


71
72
73
74
75
76
77
78
79
80
# File 'lib/mexico/file_system/layer.rb', line 71

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

Returns:

  • (Boolean)


82
83
84
85
86
# File 'lib/mexico/file_system/layer.rb', line 82

def items_form_an_edgeless_graph?
  self.items.each do |item|
    return false if item.item_links.size > 1
  end
end

#predecessor_layersObject

returns all layers that are linked to this layer such that this layer is the target, and the result layer is the source.



61
62
63
# File 'lib/mexico/file_system/layer.rb', line 61

def predecessor_layers
  document.layer_connectors.select{|c| c.target==self}.collect{|c| [c.source, c.role]}
end

#successor_layersObject

returns all layers that are linked to this layer such that this layer is the source, and the result layer is the target.



67
68
69
# File 'lib/mexico/file_system/layer.rb', line 67

def successor_layers
  document.layer_connectors.select{|c| c.source==self}.collect{|c| [c.target, c.role]}
end