Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/ruby-skyline-core.rb
Overview
EXT Array
Instance Method Summary collapse
-
#aggregate(array) ⇒ Object
skyline attributes aggregate for array.
-
#dominate?(array) ⇒ Boolean
dominate function in skyline for array.
-
#pre_check_skyline_domiante(target_array) ⇒ Object
Skyline Error Handling.
Instance Method Details
#aggregate(array) ⇒ Object
skyline attributes aggregate for array
19 20 21 22 23 24 25 26 27 |
# File 'lib/ruby-skyline-core.rb', line 19 def aggregate(array) pre_check_skyline_domiante(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) ⇒ Boolean
dominate function in skyline for array
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/ruby-skyline-core.rb', line 4 def dominate?(array) pre_check_skyline_domiante(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_domiante(target_array) ⇒ Object
Skyline Error Handling
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ruby-skyline-core.rb', line 30 def pre_check_skyline_domiante(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 |