class Array

EXT Array

Public Instance Methods

aggregate(array) click to toggle source

skyline attributes aggregate for array

# File lib/ruby-skyline-core.rb, line 19
def aggregate(array)
  pre_check_skyline_dominate(array)
  aggregate_array = []
  raise ArgumentError, "Need Array not #{array.class}"    unless array.class == Array
  each_with_index do |attr, index|
    aggregate_array << (attr + array[index]).round(6)
  end
  aggregate_array
end
dominate?(array) click to toggle source

dominate function in skyline for array

# File lib/ruby-skyline-core.rb, line 4
def dominate?(array)
  pre_check_skyline_dominate(array)
  flag       = 0
  check_flag = size
  each_with_index do |attr, index|
    flag += 1       if attr >  array[index]
    flag -= 1       if attr <  array[index]
    check_flag -= 1 if attr == array[index]
  end
  return false if flag == check_flag     # be dominated
  return true  if flag == 0 - check_flag # dominate
  nil
end
pre_check_skyline_dominate(target_array) click to toggle source

Skyline Error Handling

# File lib/ruby-skyline-core.rb, line 30
def pre_check_skyline_dominate(target_array)
  unless target_array.class == Array
    raise ArgumentError, "excpet (Array) got (#{target_array.class})" 
  end

  unless size == target_array.size
    raise ArgumentError,
      "size dosen't match, excpet (#{size}) got (#{target_array.size})"
  end
end