Method: LEON.match_layout

Defined in:
lib/io.rb

.match_layout(val, stringIndex, oli) ⇒ Object



457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
# File 'lib/io.rb', line 457

def self.match_layout(val, stringIndex, oli)
  if val.kind_of? Hash
    keys = val.keys
  elsif val.kind_of? Object
    keys = val.instance_variables.map { |v|
      v.to_s.sub("@", "")
    }
  end
  layout = Array.new
  for i in 0..(keys.length - 1)
    if keys[i].kind_of? Symbol
      keys[i] = keys[i].to_s
    end
    layout.push stringIndex.index(keys[i])
  end
  layout.sort! { |a, b|
    a <=> b
  }
  i = 0
  while i < oli.length
    if layout.eql? oli[i].sort { |a, b| a <=> b }
      return i
    end
    i += 1
  end
end