Sha256: 77686d8e2bea463fc611ce1e451d17202d82c63fd885eb2fe7975b536d2533b3

Contents?: true

Size: 1.99 KB

Versions: 21

Compression:

Stored size: 1.99 KB

Contents

# frozen_string_literal: true

require 'logger'

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
        # Exit Gracefully if CTRL+C is Pressed During Session
        Cryptum.exit_gracefully(which_self: self)
      rescue StandardError => e
        raise e
      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

21 entries across 21 versions & 1 rubygems

Version Path
cryptum-0.0.381 lib/cryptum/ui/market_trend.rb
cryptum-0.0.380 lib/cryptum/ui/market_trend.rb
cryptum-0.0.379 lib/cryptum/ui/market_trend.rb
cryptum-0.0.378 lib/cryptum/ui/market_trend.rb
cryptum-0.0.377 lib/cryptum/ui/market_trend.rb
cryptum-0.0.376 lib/cryptum/ui/market_trend.rb
cryptum-0.0.375 lib/cryptum/ui/market_trend.rb
cryptum-0.0.374 lib/cryptum/ui/market_trend.rb
cryptum-0.0.373 lib/cryptum/ui/market_trend.rb
cryptum-0.0.372 lib/cryptum/ui/market_trend.rb
cryptum-0.0.370 lib/cryptum/ui/market_trend.rb
cryptum-0.0.369 lib/cryptum/ui/market_trend.rb
cryptum-0.0.368 lib/cryptum/ui/market_trend.rb
cryptum-0.0.367 lib/cryptum/ui/market_trend.rb
cryptum-0.0.366 lib/cryptum/ui/market_trend.rb
cryptum-0.0.365 lib/cryptum/ui/market_trend.rb
cryptum-0.0.364 lib/cryptum/ui/market_trend.rb
cryptum-0.0.363 lib/cryptum/ui/market_trend.rb
cryptum-0.0.362 lib/cryptum/ui/market_trend.rb
cryptum-0.0.361 lib/cryptum/ui/market_trend.rb