Class: SocialStream::D3::Force
- Inherits:
-
Object
- Object
- SocialStream::D3::Force
- Defined in:
- lib/social_stream/d3.rb
Instance Method Summary collapse
-
#initialize(ties, view) ⇒ Force
constructor
A new instance of Force.
- #to_json ⇒ Object
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_json ⇒ Object
20 21 22 |
# File 'lib/social_stream/d3.rb', line 20 def to_json @force.to_json end |