Class: DiagramExtractor
- Inherits:
-
Object
- Object
- DiagramExtractor
- Defined in:
- lib/diagram_extractor.rb
Instance Method Summary collapse
- #extract_diagram(path, diagram_num) ⇒ Object
-
#initialize ⇒ DiagramExtractor
constructor
A new instance of DiagramExtractor.
Constructor Details
#initialize ⇒ DiagramExtractor
Returns a new instance of DiagramExtractor.
2 3 |
# File 'lib/diagram_extractor.rb', line 2 def initialize end |
Instance Method Details
#extract_diagram(path, diagram_num) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/diagram_extractor.rb', line 5 def extract_diagram(path, diagram_num) doc = File.open(path) { |f| Nokogiri::XML(f) } diagrams = doc.xpath("//mxfile//diagram") puts "Diagrams found at \"#{path}\": #{diagrams.length}. " \ "Selected: #{diagram_num}. " diagram = diagrams[diagram_num] diagram_name = diagram["name"] diagram_content = diagram.to_html return diagram_name, diagram_content end |