Class: Watchcow::Client
- Inherits:
-
Object
- Object
- Watchcow::Client
- Defined in:
- lib/watchcow/client.rb
Class Method Summary collapse
- .all_text(results) ⇒ Object
- .call(coin = nil) ⇒ Object
- .list_text(results) ⇒ Object
- .stare(coin) ⇒ Object
Class Method Details
.all_text(results) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/watchcow/client.rb', line 54 def all_text results results.map do |k, v| v.map do |c| c.values.map{|x| x} end end.inject(&:+).map do |str| "<p>#{str}</p>" end end |
.call(coin = nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/watchcow/client.rb', line 10 def call(coin=nil) results = Watchcow::Rate.call(coin) cq_list = results[:cq_list] nq_list = results[:nq_list] nw_list = results[:nw_list] cw_list = results[:cw_list] results = { cq_list: cq_list, nq_list: nq_list, nw_list: nw_list, cw_list: cw_list } results.to_json end |
.list_text(results) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/watchcow/client.rb', line 31 def list_text results cq = results.dig('cq_list') nq = results.dig('nq_list') cw = results.dig('cw_list') nw = results.dig('nw_list') best_cq = cq.first best_nq = nq.first best_cw = cw.first best_nw = nw.first text = [best_nq, best_cq, best_nw, best_cw].each do |x| t = " \#{x.dig('coin')}, \#{x.dig('days')} days left\n annual margin: \#{x.dig('margin')}%\n landed margin: \#{x.dig('real_margin_expected')}%\n dm bid: \#{x.dig('dm_first_bid')}, spot bid: \#{x.dig('spot_first_bid')}\n ---\n\n CONTENT\n puts t\n end\nend\n" |
.stare(coin) ⇒ Object
25 26 27 28 29 |
# File 'lib/watchcow/client.rb', line 25 def stare coin while true list_text(JSON.parse(call(coin))) end end |