Module: Tickerizer
- Defined in:
- lib/tickerizer.rb,
lib/tickerizer/version.rb
Defined Under Namespace
Classes: Configuration
Constant Summary collapse
- VERSION =
"0.0.1"
Class Attribute Summary collapse
-
.license_id ⇒ Object
Returns the value of attribute license_id.
Class Method Summary collapse
- .configuration ⇒ Object
- .configure {|configuration| ... } ⇒ Object
- .extract(content) ⇒ Object
- .process(data) ⇒ Object
Class Attribute Details
.license_id ⇒ Object
Returns the value of attribute license_id.
21 22 23 |
# File 'lib/tickerizer.rb', line 21 def license_id @license_id end |
Class Method Details
.configuration ⇒ Object
12 13 14 |
# File 'lib/tickerizer.rb', line 12 def self.configuration @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
16 17 18 |
# File 'lib/tickerizer.rb', line 16 def self.configure yield(configuration) if block_given? end |
.extract(content) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/tickerizer.rb', line 29 def self.extract(content) resp = Calais.enlighten( :content => content, :content_type => :raw, :output_format => :json, :license_id => Tickerizer.configuration.license_id ) self.process( JSON.parse(resp) ) end |
.process(data) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/tickerizer.rb', line 40 def self.process(data) companies = Array.new data.each do |node| if node[1]["_type"] == "Company" company = {:name => node[1]["name"], :relevance => node[1]["relevance"].to_f} company[:ticker] = node[1]["resolutions"][0]["ticker"] if node[1]["resolutions"] companies << company end end companies.sort_by{|company| company[:relevance]}.reverse! end |