Class: Graph
Class Method Summary
collapse
-
.run(opts = {}) ⇒ Object
usage params = “533c98700765e035b1000001”, term: “SNA”, nodes: [19512246, 18911399, 2192301], attributes: {“name” => {“19512246” => 1, “18911399” => 2}‘, domain: “twitter”}.
Instance Method Summary
collapse
#attribute_names, #attributes, #initialize, #parse_value, #set_as_time_if_timestamp, timestamped_keys, #to_json, #useful_attribute_names
Constructor Details
This class inherits a constructor from ResponseType
Class Method Details
.run(opts = {}) ⇒ Object
usage params = “533c98700765e035b1000001”, term: “SNA”, nodes: [19512246, 18911399, 2192301], attributes: {“name” => {“19512246” => 1, “18911399” => 2}‘, domain: “twitter”}
58
59
60
61
62
63
64
65
|
# File 'lib/response_types/graph.rb', line 58
def self.run(opts={})
opts[:api_version] ||= 1
opts[:host] ||= "0.0.0.0:8083"
client = LittleBird::Client.new(opts[:api_key], opts[:api_version], opts[:host])
sub_graph = client.graph_create(term: opts[:term])
sub_graph.add(opts[:nodes], domain: opts[:domain])
sub_graph.analyze
end
|
Instance Method Details
#add(ids, opts = {}) ⇒ Object
2
3
4
|
# File 'lib/response_types/graph.rb', line 2
def add(ids, opts={})
client.graph_add({identities: [ids].flatten, id: id}.merge(opts))
end
|
#analyze ⇒ Object
14
15
16
|
# File 'lib/response_types/graph.rb', line 14
def analyze
client.graph_analyze(id: id)
end
|
#clear_attribute(opts) ⇒ Object
25
26
27
|
# File 'lib/response_types/graph.rb', line 25
def clear_attribute(opts)
client.graph_analyze(opts.merge(id: id))
end
|
#clear_attributes(opts) ⇒ Object
18
19
20
21
22
23
|
# File 'lib/response_types/graph.rb', line 18
def clear_attributes(opts)
names = opts.delete(:names) || opts.delete("names")
names.each do |name|
client.graph_clear_attribute(opts.merge(id: id, name: name))
end
end
|
#communities(analysis_id) ⇒ Object
29
30
31
|
# File 'lib/response_types/graph.rb', line 29
def communities(analysis_id)
client.(analysis_id: analysis_id)
end
|
#communities_users(analysis_id) ⇒ Object
37
38
39
|
# File 'lib/response_types/graph.rb', line 37
def communities_users(analysis_id)
client.(analysis_id: analysis_id, users: true)
end
|
33
34
35
|
# File 'lib/response_types/graph.rb', line 33
def (analysis_id, )
client.(analysis_id: analysis_id, community_id: )
end
|
41
42
43
|
# File 'lib/response_types/graph.rb', line 41
def (analysis_id, )
client.(analysis_id: analysis_id, community_id: , users: true)
end
|
#download_csv_to(analysis_id, file = StringIO.new) ⇒ Object
10
11
12
|
# File 'lib/response_types/graph.rb', line 10
def download_csv_to(analysis_id, file=StringIO.new)
client.graph_download(analysis_id: analysis_id, format: "csv").to_file(file)
end
|
#download_gexf_to(analysis_id, file = StringIO.new) ⇒ Object
6
7
8
|
# File 'lib/response_types/graph.rb', line 6
def download_gexf_to(analysis_id, file=StringIO.new)
client.graph_download(analysis_id: analysis_id, format: "gexf").to_file(file)
end
|
#drop ⇒ Object
45
46
47
|
# File 'lib/response_types/graph.rb', line 45
def drop
client.graph_drop(id: id)
end
|
#info ⇒ Object
49
50
51
|
# File 'lib/response_types/graph.rb', line 49
def info
client.graph_info(id: id)
end
|
#set_attribute ⇒ Object
53
54
55
|
# File 'lib/response_types/graph.rb', line 53
def set_attribute
client.graph_set_attribute(opts.merge(id: id))
end
|