Sha256: 9777999e919f62fea2bf31a1d50a99df357c7554d9fb2e1e1e3709751d8d2f27

Contents?: true

Size: 1.93 KB

Versions: 9

Compression:

Stored size: 1.93 KB

Contents

# frozen_string_literal: true

module Cryptum
  # This plugin is used to Refresh the Cryptum console UI
  module UI
    module MarketTrend
      # Supported Method Parameters::
      # Cryptum::UI::Candle.refresh(
      #   order_book: 'required - Order Book Data Structure',
      #   event: 'required - Event from Coinbase Web Socket'
      # )

      public_class_method def self.refresh(opts = {})
        market_trend_win = opts[:market_trend_win]
        event_history = opts[:event_history]
        event = opts[:event]
        indicator_status = opts[:indicator_status]

        indicator_hash = Cryptum::OrderBook::MarketTrend.status(
          event_history: event_history,
          event: event,
          indicator_status: indicator_status
        )

        market_trend_color = indicator_hash[:color]
        market_trend_out = indicator_hash[:ui]

        # UI
        # ROW 1
        out_line_no = 0
        Cryptum::UI.line(
          ui_win: market_trend_win,
          out_line_no: out_line_no
        )

        # ROW 2
        out_line_no += 1
        market_trend_win.setpos(out_line_no, Cryptum::UI.col_first)
        market_trend_win.clrtoeol

        market_trend_win.setpos(
          out_line_no,
          Cryptum::UI.col_center(str: market_trend_out)
        )

        Cryptum::UI.colorize(
          ui_win: market_trend_win,
          color: market_trend_color,
          style: :bold,
          string: market_trend_out
        )

        market_trend_win.refresh

        event_history
      rescue Interrupt, StandardError => e
        Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
      end

      # Display Usage for this Module

      public_class_method def self.help
        puts "USAGE:
         #{self}.refresh(
           order_book: 'required - Order Book Data Structure',
           event: 'required - Event from Coinbase Web Socket'
         )
        "
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
cryptum-0.0.397 lib/cryptum/ui/market_trend.rb
cryptum-0.0.396 lib/cryptum/ui/market_trend.rb
cryptum-0.0.395 lib/cryptum/ui/market_trend.rb
cryptum-0.0.394 lib/cryptum/ui/market_trend.rb
cryptum-0.0.393 lib/cryptum/ui/market_trend.rb
cryptum-0.0.392 lib/cryptum/ui/market_trend.rb
cryptum-0.0.389 lib/cryptum/ui/market_trend.rb
cryptum-0.0.388 lib/cryptum/ui/market_trend.rb
cryptum-0.0.387 lib/cryptum/ui/market_trend.rb