Class: GraphML::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-graphml.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs, graph) ⇒ Node

Returns a new instance of Node.



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/ruby-graphml.rb', line 59

def initialize(attrs, graph)
  attrs.each do |key, val|
    if key == 'id'
      @id = val
    end
  end
  @data = {}
  @in_edges = []
  @out_edges = []
  @graph = graph
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



58
59
60
# File 'lib/ruby-graphml.rb', line 58

def data
  @data
end

#idObject

Returns the value of attribute id.



58
59
60
# File 'lib/ruby-graphml.rb', line 58

def id
  @id
end

#in_edgesObject

Returns the value of attribute in_edges.



58
59
60
# File 'lib/ruby-graphml.rb', line 58

def in_edges
  @in_edges
end

#out_edgesObject

Returns the value of attribute out_edges.



58
59
60
# File 'lib/ruby-graphml.rb', line 58

def out_edges
  @out_edges
end

Instance Method Details

#key(name) ⇒ Object



71
72
73
74
75
76
# File 'lib/ruby-graphml.rb', line 71

def key(name)
  key_obj = @graph.key_names[name]
  val = @data[key_obj.id]
  return key_obj.default if val.nil?
  val
end