jsontonetworkgraph 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/jsontonetworkgraph.rb +14 -0
  2. data/lib/link.rb +5 -1
  3. metadata +2 -2
@@ -49,10 +49,24 @@ class JSONToNetworkGraph
49
49
  end
50
50
  end
51
51
 
52
+ def linkCount
53
+ @linkhash.each_value do |l|
54
+ count1 = @nodehash[l.instance_variable_get(:@field1)].instance_variable_get(:@linkcount)
55
+ count2 = @nodehash[l.instance_variable_get(:@field2)].instance_variable_get(:@linkcount)
56
+
57
+ if count1 > count2
58
+ l.linkCount(count2)
59
+ else
60
+ l.linkCount(count1)
61
+ end
62
+ end
63
+ end
64
+
52
65
  # Generate JSON with nodes and links
53
66
  def genJSON
54
67
  genNodes
55
68
  genLinks
69
+ linkCount
56
70
 
57
71
  nodearray = Array.new
58
72
  @nodehash.each_value do |n|
data/lib/link.rb CHANGED
@@ -12,7 +12,11 @@ class Link
12
12
  @value.push(toadd)
13
13
  end
14
14
 
15
+ def linkCount(num)
16
+ @lowestLinkCount = num
17
+ end
18
+
15
19
  def linkData
16
- link_hash = {:source => @source, :target => @target, :field1 => @field1, :field2 => @field2, :data => @value}
20
+ link_hash = {:source => @source, :target => @target, :field1 => @field1, :field2 => @field2, :lowestLinkCount => @lowestLinkCount, :data => @value}
17
21
  end
18
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsontonetworkgraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-20 00:00:00.000000000 Z
12
+ date: 2014-02-21 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Generates node and link data from any JSON.
15
15
  email: shidash@shidash.com