Class: Wewoo::Edge

Inherits:
Element show all
Includes:
Adapter
Defined in:
lib/wewoo/edge.rb

Instance Attribute Summary collapse

Attributes inherited from Element

#graph, #id, #properties

Instance Method Summary collapse

Methods included from Adapter

delete, get, handle_response, log, logger, post, put

Methods inherited from Element

#gid

Instance Attribute Details

#from_idObject

Returns the value of attribute from_id.



7
8
9
# File 'lib/wewoo/edge.rb', line 7

def from_id
  @from_id
end

#labelObject

Returns the value of attribute label.



7
8
9
# File 'lib/wewoo/edge.rb', line 7

def label
  @label
end

#to_idObject

Returns the value of attribute to_id.



7
8
9
# File 'lib/wewoo/edge.rb', line 7

def to_id
  @to_id
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



9
10
11
12
13
14
15
16
# File 'lib/wewoo/edge.rb', line 9

def ==( other )
  self.class   == other.class and
  self.id      == other.id and
  self.from_id == other.from_id and
  self.to_id   == other.to_id and
  self.label   == other.label and
  self.props   == other.props
end

#destroyObject



32
33
34
# File 'lib/wewoo/edge.rb', line 32

def destroy
  graph.remove_edge( id )
end

#get_vertex(direction) ⇒ Object



20
21
22
23
# File 'lib/wewoo/edge.rb', line 20

def get_vertex( direction )
  id = (direction == :in ? to_id : from_id)
  graph.find_vertex( id )
end

#hashObject



18
# File 'lib/wewoo/edge.rb', line 18

def hash; id; end

#inObject



24
# File 'lib/wewoo/edge.rb', line 24

def in;  @in  || get_vertex(:in); end

#outObject



25
# File 'lib/wewoo/edge.rb', line 25

def out; @out || get_vertex(:out); end

#to_sObject Also known as: inspect



27
28
29
# File 'lib/wewoo/edge.rb', line 27

def to_s
  "e(#{self.id}) [#{from_id}-#{label}-#{to_id}]"
end