class KbColors

Attributes

header[RW]
kb_colors[RW]
title[RW]

Public Class Methods

new(opts = {}) click to toggle source
# File lib/kb_colors.rb, line 8
def initialize(opts = {})
  @kb_colors = Array.new()
  @title = ""
  case opts[:kb_version]
  when "KBX3"
    @header = "Copyright RUIFAN"
    ;;
  when "KBX5"
    @header = "Copyright RUIFAN:KBX5"
    ;;
  else
    @header = "Copyright RUIFAN"
  end

  @max_length = 15
  if opts[:title]
    @title = opts[:title]
  end
end

Public Instance Methods

add_color(r = 0, g = 0, b = 0, v = 0, a = 0) click to toggle source
# File lib/kb_colors.rb, line 28
def add_color(r = 0, g = 0, b = 0, v = 0, a = 0)
  if @kb_colors.length >= @max_length
    return false
  end
  kb_color = KbColor.new()
  kb_color.r = r % 256
  kb_color.g = g % 256
  kb_color.b = b % 256
  kb_color.v = v % 256
  kb_color.a = a % 256
  @kb_colors.push kb_color
  return @kb_colors.length
end
delete_at(at) click to toggle source
# File lib/kb_colors.rb, line 46
def delete_at(at)
  if at.nil? or at >= @kb_colors.length - 1
    return false
  end
  @kb_colors.delete_at at
  return self
end
length() click to toggle source
# File lib/kb_colors.rb, line 54
def length()
  return @kb_colors.length
end
set_title(tmp_title = "") click to toggle source
# File lib/kb_colors.rb, line 42
def set_title(tmp_title = "")
  @title = tmp_title
end
to_s() click to toggle source
# File lib/kb_colors.rb, line 58
def to_s()
  s = ""
  s += @header.to_s + "\n"
  s += @title.to_s + "\n"
  if @kb_colors
    @kb_colors.each do |kb_color|
      s += kb_color.to_s + "\n"
    end
  end
  return s
end