Module: Adiwg_Coordinates

Defined in:
lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.9.0/module_coordinates.rb

Overview

History: Stan Smith 2013-11-07 original script Stan Smith 2013-11-13 added getDimension

Stan Smith 2014-05-23 added getLevels

Class Method Summary collapse

Class Method Details

.getDimension(aCoords) ⇒ Object

get the number of dimensions in a coordinate array



33
34
35
36
37
38
39
40
41
# File 'lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.9.0/module_coordinates.rb', line 33

def self.getDimension(aCoords)
  if aCoords[0].kind_of?(Array)
    coordDim = getDimension(aCoords[0])
  else
    coordDim = aCoords.length
  end

  return coordDim
end

.getLevels(aCoords) ⇒ Object

get the number of levels in the coordinate array



44
45
46
47
48
49
50
# File 'lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.9.0/module_coordinates.rb', line 44

def self.getLevels(aCoords)
  i = 1
  if aCoords[0].kind_of?(Array)
    i = i + getLevels(aCoords[0])
  end
  return i
end

.unpack(aCoords) ⇒ Object

repack coordinate array into single string for ISO



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.9.0/module_coordinates.rb', line 12

def self.unpack(aCoords)
  s = ''
  i = 0
  coordCount = aCoords.length
  aCoords.each do |coord|
    if coord.kind_of?(Array)
      s = s + unpack(coord)
    else
      i += 1
      s = s + coord.to_s
      if i < coordCount
        s = s + ','
      end
      s = s + ' '
    end
  end

  return s
end