<commit_before>require 'singleton'
require 'bundler'
Bundler.require

class UserWindow
  include Singleton
  include Curses

  def initialize
    @window = stdscr.subwin(0, 30, 0, stdscr.maxx - 30)
  end

  def update(user)
    fail ArgumentError, 'Augument must be a user' unless user.is_a? User
    @user = user
    refresh_window
  end

  def refresh_window
    @window.clear

    @window.attron(A_BOLD)
    @window.setpos(1, 2)
    @window.addstr(@user.name)
    @window.setpos(2, 2)
    @window.addstr("@#{@user.screen_name}")
    @window.attroff(A_BOLD)

    @user.description.split_by_width(@window.maxx - 2).each.with_index(0) do |line, i|
      @window.setpos(4 + i, 2)
      @window.addstr(line)
    end

    draw_border

    @window.refresh
  end

  private

  def draw_border
    @window.attron(color_pair(4))
    @window.maxy.times do |i|
      @window.setpos(i, 0)
      @window.addch('|')
    end
    @window.attroff(color_pair(4))
  end
end
<commit_msg>Display statuses/friends/followers counts in user info window<commit_after>require 'singleton'
require 'bundler'
Bundler.require

class UserWindow
  include Singleton
  include Curses

  def initialize
    @window = stdscr.subwin(0, 30, 0, stdscr.maxx - 30)
  end

  def update(user)
    fail ArgumentError, 'Augument must be a user' unless user.is_a? User
    @user = user
    refresh_window
  end

  def refresh_window
    @window.clear

    @window.attron(A_BOLD)
    @window.setpos(1, 2)
    @window.addstr(@user.name)
    @window.setpos(2, 2)
    @window.addstr("@#{@user.screen_name}")
    @window.attroff(A_BOLD)

    max_len = [:statuses_count, :friends_count, :followers_count].map { |method| @user.send(method) }.map(&:format).map(&:length).max
    @window.setpos(4, 2)
    @window.addstr("#{@user.statuses_count.format} tweets  ".rjust(@window.maxx - 2))
    @window.setpos(5, 2)
    @window.addstr("#{@user.friends_count.format} following  ".rjust(@window.maxx - 2))
    @window.setpos(6, 2)
    @window.addstr("#{@user.followers_count.format} followers  ".rjust(@window.maxx - 2))

    @user.description.split_by_width(@window.maxx - 4).each.with_index(0) do |line, i|
      @window.setpos(8 + i, 2)
      @window.addstr(line)
    end

    draw_border

    @window.refresh
  end

  private

  def draw_border
    @window.attron(color_pair(4))
    @window.maxy.times do |i|
      @window.setpos(i, 0)
      @window.addch('|')
    end
    @window.attroff(color_pair(4))
  end
end

{'fraction_non_alphanumeric': 0.13861788617886178, 'fraction_numerical': 0.017479674796747967, 'mean_word_length': 3.265164644714038, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7341304', 'n_tokens_mistral': 968, 'n_tokens_neox': 926, 'n_words': 179}