Class: YaCan::Dependency::Chunk
- Inherits:
-
Object
- Object
- YaCan::Dependency::Chunk
- Defined in:
- lib/yacan/dependency.rb
Instance Attribute Summary collapse
-
#dependency ⇒ Object
readonly
Returns the value of attribute dependency.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#morphems ⇒ Object
readonly
Returns the value of attribute morphems.
Instance Method Summary collapse
- #depends_from ⇒ Object
- #depends_on ⇒ Object
-
#initialize(xml, chunks) ⇒ Chunk
constructor
A new instance of Chunk.
- #to_s ⇒ Object
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
#dependency ⇒ Object (readonly)
Returns the value of attribute dependency.
48 49 50 |
# File 'lib/yacan/dependency.rb', line 48 def dependency @dependency end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
48 49 50 |
# File 'lib/yacan/dependency.rb', line 48 def id @id end |
#morphems ⇒ Object (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_from ⇒ Object
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_on ⇒ Object
40 41 42 |
# File 'lib/yacan/dependency.rb', line 40 def depends_on @depends_o ||= @chunks.call.find{ |c| c.id == @dependency } end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/yacan/dependency.rb', line 36 def to_s "#{@id} #{dependency} #{@morphems.map{ |m| m.surface}.join('')}" end |