module Facy::Output

Public Instance Methods

_post_code_table_loop(prefix, max_length) click to toggle source
# File lib/facy/output.rb, line 117
def _post_code_table_loop(prefix, max_length)
  post_code_table << prefix if prefix.length > 0
  if prefix.length < max_length
    ('a'..'z').each do |char|
      _post_code_table_loop(prefix + char, max_length)
    end
  end
end
clear_line() click to toggle source
# File lib/facy/output.rb, line 57
def clear_line
  Readline.refresh_line
end
error(text) click to toggle source
# File lib/facy/output.rb, line 49
def error(text)
  instant_output(Item.new(info: :error, content: text))
end
instant_output(item) click to toggle source
# File lib/facy/output.rb, line 26
def instant_output(item)
  sync { printed_item << item.id if item.id }
  info = item.info
  print_registers.each do |pattern|
    if info == pattern[:name]
      pattern[:block].call(item)
    end
  end
rescue
end
new_line() click to toggle source
# File lib/facy/output.rb, line 53
def new_line
  puts ''
end
not_yet_print_items() click to toggle source
# File lib/facy/output.rb, line 12
def not_yet_print_items
  items = []
  while !stream_print_queue.empty?
    post = stream_print_queue.pop
    items << post unless printed_item.include? post.id
  end

  while !notification_print_queue.empty?
    notify = notification_print_queue.pop
    items << notify unless printed_item.include? notify.id
  end
  return items
end
periodic_output() click to toggle source
# File lib/facy/output.rb, line 5
def periodic_output
  return if (items = not_yet_print_items).empty?
  new_line
  items.each {|item| instant_output(item)}
  clear_line
end
post_code(item) click to toggle source
# File lib/facy/output.rb, line 86
def post_code(item)
  post_id = item.id

  return post_code_map[post_id] if post_code_map[post_id]
  post_code_table_load if post_code_table.empty?
  code = post_code_table.pop

  post_code_reverse_map[code] = item
  post_code_map[post_id] = code

  return code 
end
post_code_map() click to toggle source
# File lib/facy/output.rb, line 103
def post_code_map
  @post_code_map ||= {}
end
post_code_reverse_map() click to toggle source
# File lib/facy/output.rb, line 107
def post_code_reverse_map
  @post_code_reverse_map ||= {}
end
post_code_table() click to toggle source
# File lib/facy/output.rb, line 99
def post_code_table
  @post_code_table ||= []
end
post_code_table_load() click to toggle source
# File lib/facy/output.rb, line 111
def post_code_table_load
  max_length = 3
  _post_code_table_loop('$', max_length)
  post_code_table.sort!
end
print_register(item_name, &block) click to toggle source
print_registers() click to toggle source
stop_animation() click to toggle source
# File lib/facy/output.rb, line 45
def stop_animation
  @stop_animation ||= true
end
username_color(uname) click to toggle source
# File lib/facy/output.rb, line 80
def username_color(uname)
  return username_color_map[uname] if username_color_map[uname]
  username_color_table_load if username_color_table.empty?
  return (username_color_map[uname] = username_color_table.pop)
end
username_color_map() click to toggle source
# File lib/facy/output.rb, line 61
def username_color_map
  @username_color_map ||= {}
end
username_color_table() click to toggle source
# File lib/facy/output.rb, line 65
def username_color_table
  @username_color_table ||= []
end
username_color_table_load() click to toggle source
# File lib/facy/output.rb, line 69
def username_color_table_load
  max_range = 256 
  step      = 9
  start     = current = 1
  (1..max_range).each do |col|
    username_color_table << [38,5,current]
    current = current + step
    current = current % max_range if current > max_range
  end
end