class Limb

Attributes

draw_data[R]
end_x[R]
end_y[R]

Public Class Methods

new(params, x0, y0, opts = {}) click to toggle source
# File lib/limbs/limb.rb, line 8
def initialize(params, x0, y0, opts = {})
  @params = params
  @x0 = x0
  @end_y = @y0 = y0
  @draw_data = []
  @opts = opts
  @name, @color_limb = process_item(params[:name])
  body_color = apply_body_color(@opts[:body_color]) if @opts.key?(:body_color)
  @color_limb = body_color unless body_color.nil? || body_color == :black

  draw
end

Private Instance Methods

apply_body_color(body_color) click to toggle source
# File lib/limbs/limb.rb, line 43
def apply_body_color(body_color)
  return body_color if body_color == :green || body_color == :red
end
compute_limb_length() click to toggle source
# File lib/limbs/limb.rb, line 27
def compute_limb_length
  @params[:length] <= Config::METHOD_LENGTH_OK_MAX ? Config::LIMB_LENGTH * orientation : Config::LIMB_LENGTH_LONG * orientation
end
draw() click to toggle source
# File lib/limbs/limb.rb, line 23
def draw
  @limb_length = compute_limb_length
end
draw_conditions() click to toggle source
# File lib/limbs/limb.rb, line 36
def draw_conditions; end
orientation() click to toggle source
# File lib/limbs/limb.rb, line 31
def orientation
  return 1 if @opts[:body_side].nil?
  @opts[:body_side] == :left ? -1 : 1
end
set_additional_colors(items, value) click to toggle source
# File lib/limbs/limb.rb, line 38
def set_additional_colors(items, value)
  return [@color_limb] * items if @color_limb == :green || @color_limb == :red
  return value
end