Class: SemanticHacker::Api
- Inherits:
-
Object
- Object
- SemanticHacker::Api
show all
- Includes:
- HTTParty
- Defined in:
- lib/semantic_hacker/api.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
4
5
6
|
# File 'lib/semantic_hacker/api.rb', line 4
def api_key
@api_key
end
|
Class Method Details
.about ⇒ Object
9
10
11
|
# File 'lib/semantic_hacker/api.rb', line 9
def self.about
OpenStruct.new(@data["about"].map { |x| [ x[0].dup.to_underscore, x[1] ] } )
end
|
.generate ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/semantic_hacker/api.rb', line 13
def self.generate
data = @data.dup
content_path.each{|x| data = data[x]}
result = Hash[data.map do |l|
if l.has_key?("index")
label = SemanticHacker.labels[l["index"]]
elsif l.has_key?("id")
label = SemanticHacker.categories[l["id"]]
else
label = l["label"]
end
[ label, l["weight"]]
end.collect]
return {:about => about, content_path.last.to_sym => result}
end
|