Module: RGFA::Containments
- Included in:
- RGFA
- Defined in:
- lib/rgfa/containments.rb
Overview
Methods for the RGFA class, which allow to handle containments in the graph.
Instance Method Summary collapse
-
#contained_in(s) ⇒ Array<RGFA::Line::Containment>
Find containment lines whose
from
segment name issegment_name
. -
#containing(s) ⇒ Array<RGFA::Line::Containment>
Find containment lines whose
to
segment name issegment_name
. -
#containment(container, contained) ⇒ RGFA::Line::Containment?
Searches a containment of
contained
incontainer
. -
#containment!(container, contained) ⇒ RGFA::Line::Containment
Searches a containment of
contained
incontainer
. -
#containments ⇒ Array<RGFA::Line::Containment>
All containments in the graph.
-
#containments_between(container, contained) ⇒ Array<RGFA::Line::Containment>
Searches all containments of
contained
incontainer
. -
#delete_containment(c) ⇒ RGFA
Delete a containment.
Instance Method Details
#contained_in(s) ⇒ Array<RGFA::Line::Containment>
Find containment lines whose from
segment name is segment_name
46 47 48 49 |
# File 'lib/rgfa/containments.rb', line 46 def contained_in(s) s = segment!(s) s.containments[:from][:+] + s.containments[:from][:-] end |
#containing(s) ⇒ Array<RGFA::Line::Containment>
Find containment lines whose to
segment name is segment_name
54 55 56 57 |
# File 'lib/rgfa/containments.rb', line 54 def containing(s) s = segment!(s) s.containments[:to][:+] + s.containments[:to][:-] end |
#containment(container, contained) ⇒ RGFA::Line::Containment?
Searches a containment of contained
in container
. Returns the first containment found or nil if none found.
76 77 78 79 80 81 82 83 |
# File 'lib/rgfa/containments.rb', line 76 def containment(container, contained) contained_in(container).each do |l| if l.to.to_sym == contained.to_sym return l end end return nil end |
#containment!(container, contained) ⇒ RGFA::Line::Containment
Searches a containment of contained
in container
. Raises an exception if no such containment was found.
91 92 93 94 95 |
# File 'lib/rgfa/containments.rb', line 91 def containment!(container, contained) c = containment(container, contained) raise RGFA::LineMissingError, "No containment was found" if c.nil? c end |
#containments ⇒ Array<RGFA::Line::Containment>
All containments in the graph
39 40 41 |
# File 'lib/rgfa/containments.rb', line 39 def containments @containments end |
#containments_between(container, contained) ⇒ Array<RGFA::Line::Containment>
Searches all containments of contained
in container
. Returns a possibly empty array of containments.
67 68 69 |
# File 'lib/rgfa/containments.rb', line 67 def containments_between(container, contained) contained_in(container).select {|l| l.to.to_sym == contained.to_sym } end |
#delete_containment(c) ⇒ RGFA
Delete a containment
31 32 33 34 35 |
# File 'lib/rgfa/containments.rb', line 31 def delete_containment(c) @containments.delete(c) segment(c.from).containments[:from][c.from_orient].delete(c) segment(c.to).containments[:to][c.to_orient].delete(c) end |