Class: YaCan::Dependency::Chunk

Inherits:
Object
  • Object
show all
Defined in:
lib/yacan/dependency.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml, chunks) ⇒ Chunk

Returns a new instance of Chunk.



29
30
31
32
33
34
# File 'lib/yacan/dependency.rb', line 29

def initialize(xml, chunks)
  @id = xml.at('Id').text.to_i
  @dependency = xml.at('Dependency').text.to_i
  @morphems = xml.search('Morphem').map{ |m| Morphem.new(m) }
  @chunks = chunks
end

Instance Attribute Details

#dependencyObject (readonly)

Returns the value of attribute dependency.



48
49
50
# File 'lib/yacan/dependency.rb', line 48

def dependency
  @dependency
end

#idObject (readonly)

Returns the value of attribute id.



48
49
50
# File 'lib/yacan/dependency.rb', line 48

def id
  @id
end

#morphemsObject (readonly)

Returns the value of attribute morphems.



48
49
50
# File 'lib/yacan/dependency.rb', line 48

def morphems
  @morphems
end

Instance Method Details

#depends_fromObject



44
45
46
# File 'lib/yacan/dependency.rb', line 44

def depends_from
  @depends_f ||= @chunks.call.find_all{ |c| c.dependency == @id }
end

#depends_onObject



40
41
42
# File 'lib/yacan/dependency.rb', line 40

def depends_on
  @depends_o ||= @chunks.call.find{ |c| c.id == @dependency }
end

#to_sObject



36
37
38
# File 'lib/yacan/dependency.rb', line 36

def to_s
  "#{@id} #{dependency} #{@morphems.map{ |m| m.surface}.join('')}"
end