Class: SocialFramework::NetworkHelper::GraphStrategy

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/social_framework/network_helper.rb

Overview

Define a Abstract Class to Network Graph

Direct Known Subclasses

GraphStrategyDefault

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#depthObject

Maximum depth graph



13
14
15
# File 'app/helpers/social_framework/network_helper.rb', line 13

def depth
  @depth
end

#networkObject

Array of verteces



11
12
13
# File 'app/helpers/social_framework/network_helper.rb', line 11

def network
  @network
end

Class Method Details

.get_instance(id, elements_factory) ⇒ Object

Get graph instance to user logged

Params:
id

Integer Id of the user logged

elements_factory

String Represent the factory class name to build

Returns NotImplementedError



24
25
26
# File 'app/helpers/social_framework/network_helper.rb', line 24

def self.get_instance(id, elements_factory)
  raise 'Must implement method in subclass'
end

Instance Method Details

#build(root, attributes, relationships) ⇒ Object

Mount a graph from an user

Params:
root

User Root user to mount graph

attributes

Array Attributes will be added in vertex

relationships

Array labels to find relationships, can be multiple in array or just one in a simple String, default is “all” thats represents all relationships existing

Returns NotImplementedError



42
43
44
# File 'app/helpers/social_framework/network_helper.rb', line 42

def build(root, attributes, relationships)
  raise 'Must implement method in subclass'
end

#destroy(id) ⇒ Object

Destroy graph instance with id passed

Params:
id

Integer Id of the user logged

Returns NotImplementedError



32
33
34
# File 'app/helpers/social_framework/network_helper.rb', line 32

def destroy(id)
  raise 'Must implement method in subclass'
end

#search(map, search_in_progress, elements_number) ⇒ Object

Search users with values specified in a map

Params:
map

Hash with keys and values to compare

search_in_progress

Boolean to continue if true or start a new search

elements_number

Integer to limit max search result

Returns NotImplementedError



52
53
54
# File 'app/helpers/social_framework/network_helper.rb', line 52

def search(map, search_in_progress, elements_number)
  raise 'Must implement method in subclass'
end

#suggest_relationships(type_relationships, amount_relationships) ⇒ Object

Suggest relationships to root

Params:
type_relationships

Array labels to find relationships, can be multiple in array or just one in a simple String

amount_relationships

Integer quantity of relationships to suggest a new relationship

Returns NotImplementedError



61
62
63
# File 'app/helpers/social_framework/network_helper.rb', line 61

def suggest_relationships(type_relationships, amount_relationships)
  raise 'Must implement method in subclass'
end