Class: Ruxster::Edge
- Inherits:
-
Base
- Object
- Base
- Ruxster::Edge
show all
- Defined in:
- lib/ruxster/edge.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
connect_string, #create, create_index, #destroy, find, get, #id, #id=, indices, #parameterize, #properties_hash, #type, #type=, #update
Constructor Details
#initialize(hash = {}) ⇒ Edge
Returns a new instance of Edge.
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/ruxster/edge.rb', line 13
def initialize(hash={})
hash.each do |key, value|
case key.to_s
when "id"
self.id = value
when "_id"
self.id = value
when "type"
self.type = value
when "_type"
self.type = value
when "_label"
self.label = value
when "label"
self.label = value
when "weight"
self.weight = value
when "_inV"
self.in_vertex = value
when "in_vertex"
self.in_vertex = value
when "_outV"
self.out_vertex = value
when "out_vertex"
self.out_vertex = value
end
end
end
|
Class Method Details
.all ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/ruxster/edge.rb', line 84
def self.all
objects = []
response = Excon.get(Vertex.connect_string + "/edges")
if response
results = JSON.parse(response.body)["results"]
if results
results.each do |hash|
objects << self.new(hash)
end
end
end
objects
end
|
.create(hash = {}) ⇒ Object
78
79
80
81
82
|
# File 'lib/ruxster/edge.rb', line 78
def self.create(hash={})
edge = Edge.new(hash)
edge.create
edge
end
|
.index_type ⇒ Object
9
10
11
|
# File 'lib/ruxster/edge.rb', line 9
def self.index_type
"edge"
end
|
.url_directory ⇒ Object
6
7
8
|
# File 'lib/ruxster/edge.rb', line 6
def self.url_directory
"edges"
end
|
Instance Method Details
#in_vertex ⇒ Object
56
57
58
|
# File 'lib/ruxster/edge.rb', line 56
def in_vertex
Vertex.get(self.properties_hash["_inV"])
end
|
#in_vertex=(value) ⇒ Object
59
60
61
62
63
64
65
|
# File 'lib/ruxster/edge.rb', line 59
def in_vertex=(value)
if value.class == Vertex
self.properties_hash["_inV"] = value["_id"]
else
self.properties_hash["_inV"] = value
end
end
|
#label ⇒ Object
42
43
44
|
# File 'lib/ruxster/edge.rb', line 42
def label
self.properties_hash["_label"]
end
|
#label=(value) ⇒ Object
45
46
47
|
# File 'lib/ruxster/edge.rb', line 45
def label=(value)
self.properties_hash["_label"] = value
end
|
#out_vertex ⇒ Object
67
68
69
|
# File 'lib/ruxster/edge.rb', line 67
def out_vertex
Vertex.get(self.properties_hash["_outV"])
end
|
#out_vertex=(value) ⇒ Object
70
71
72
73
74
75
76
|
# File 'lib/ruxster/edge.rb', line 70
def out_vertex=(value)
if value.class == Vertex
self.properties_hash["_outV"] = value["_id"]
else
self.properties_hash["_outV"] = value
end
end
|
#weight ⇒ Object
49
50
51
|
# File 'lib/ruxster/edge.rb', line 49
def weight
self.properties_hash["weight"]
end
|
#weight=(value) ⇒ Object
52
53
54
|
# File 'lib/ruxster/edge.rb', line 52
def weight=(value)
self.properties_hash["weight"] = value.to_i
end
|