Class: GEXF::Document
- Inherits:
-
Nokogiri::XML::SAX::Document
- Object
- Nokogiri::XML::SAX::Document
- GEXF::Document
- Defined in:
- lib/gexf/document.rb
Instance Attribute Summary collapse
-
#graph ⇒ Object
readonly
Returns the value of attribute graph.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
Class Method Summary collapse
Instance Method Summary collapse
- #characters(chars) ⇒ Object
- #end_element(tagname) ⇒ Object
- #start_document ⇒ Object
- #start_element(tagname, attributes) ⇒ Object
Instance Attribute Details
#graph ⇒ Object (readonly)
Returns the value of attribute graph.
12 13 14 |
# File 'lib/gexf/document.rb', line 12 def graph @graph end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
12 13 14 |
# File 'lib/gexf/document.rb', line 12 def @meta end |
Class Method Details
.parse(thing) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/gexf/document.rb', line 3 def self.parse(thing) document = self.new ::Nokogiri::XML::SAX::Parser.new(document). parse(thing.read) thing.close document.graph end |
Instance Method Details
#characters(chars) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/gexf/document.rb', line 46 def characters(chars) chars = chars.strip case @current_tag when 'default' @attr.default = chars end end |
#end_element(tagname) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/gexf/document.rb', line 30 def end_element(tagname) case tagname when 'attributes' @attr_class = nil when 'attribute' @attr = nil when 'node' @node = nil when 'edge' @edge = nil end @current_tag_attrs = {} @current_tag = nil end |
#start_document ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/gexf/document.rb', line 14 def start_document @graph = nil @node = nil @edge = nil @attr_class = nil @attr = nil @defined_attrs = {} end |
#start_element(tagname, attributes) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/gexf/document.rb', line 23 def start_element(tagname, attributes) @current_tag = tagname @current_tag_attrs = attributes dispatch_event(tagname, sanitize_attrs(attributes)) end |