Class: SocialStream::D3::Force

Inherits:
Object
  • Object
show all
Defined in:
lib/social_stream/d3.rb

Instance Method Summary collapse

Constructor Details

#initialize(ties, view) ⇒ Force

Returns a new instance of Force.



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/social_stream/d3.rb', line 6

def initialize(ties, view)
  @view = view

  @force =
    ties.inject({ :nodes => [], :links => [] }) { |result, t|
      add_node(result[:nodes], t.sender)
      add_node(result[:nodes], t.receiver)

      add_link(result[:links], t, result[:nodes])

      result
    }
end

Instance Method Details

#to_jsonObject



20
21
22
# File 'lib/social_stream/d3.rb', line 20

def to_json
  @force.to_json
end