Sha256: 18115b9d3ac18191bfc220074b1f501e915c1be093d25bbb68d725a6d8636ea9

Contents?: true

Size: 1.5 KB

Versions: 16

Compression:

Stored size: 1.5 KB

Contents

# repack coordinates

# History:
# 	Stan Smith 2013-11-07 original script
# 	Stan Smith 2013-11-13 added getDimension
#   Stan Smith 2014-05-23 added getLevels
#   Stan Smith 2014-12-15 refactored to handle namespacing readers and writers
#   Stan Smith 2015-06-22 replace global ($response) with passed in object (responseObj)
#   Stan Smith 2015-07-14 refactored to remove global namespace constants
#   Stan Smith 2015-07-16 moved module_coordinates from mdJson reader to internal

module AdiwgCoordinates

    # repack coordinate array into single string for ISO
    def self.unpack(aCoords, responseObj)
        s = ''
        i = 0
        coordCount = aCoords.length
        aCoords.each do |coord|
            if coord.kind_of?(Array)
                s = s + unpack(coord, responseObj)
            else
                i += 1
                s = s + coord.to_s
                if i < coordCount
                    s = s + ','
                end
                s = s + ' '
            end
        end

        return s
    end

    # get the number of dimensions in a coordinate array
    def self.getDimension(aCoords)
        if aCoords[0].kind_of?(Array)
            coordDim = getDimension(aCoords[0])
        else
            coordDim = aCoords.length
        end

        return coordDim
    end

    # get the number of levels in the coordinate array
    def self.getLevels(aCoords)
        i = 1
        if aCoords[0].kind_of?(Array)
            i = i + getLevels(aCoords[0])
        end
        return i
    end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
adiwg-mdtranslator-1.4.0 lib/adiwg/mdtranslator/internal/module_coordinates.rb
adiwg-mdtranslator-1.4.0.beta14 lib/adiwg/mdtranslator/internal/module_coordinates.rb
adiwg-mdtranslator-1.4.0.beta13 lib/adiwg/mdtranslator/internal/module_coordinates.rb
adiwg-mdtranslator-1.4.0.beta12 lib/adiwg/mdtranslator/internal/module_coordinates.rb
adiwg-mdtranslator-1.4.0.beta11 lib/adiwg/mdtranslator/internal/module_coordinates.rb
adiwg-mdtranslator-1.4.0.beta10 lib/adiwg/mdtranslator/internal/module_coordinates.rb
adiwg-mdtranslator-1.4.0.beta9 lib/adiwg/mdtranslator/internal/module_coordinates.rb
adiwg-mdtranslator-1.4.0.beta8 lib/adiwg/mdtranslator/internal/module_coordinates.rb
adiwg-mdtranslator-1.4.0.beta7 lib/adiwg/mdtranslator/internal/module_coordinates.rb
adiwg-mdtranslator-1.4.0.beta6 lib/adiwg/mdtranslator/internal/module_coordinates.rb
adiwg-mdtranslator-1.4.0.beta5 lib/adiwg/mdtranslator/internal/module_coordinates.rb
adiwg-mdtranslator-1.4.0.beta4 lib/adiwg/mdtranslator/internal/module_coordinates.rb
adiwg-mdtranslator-1.4.0.beta3 lib/adiwg/mdtranslator/internal/module_coordinates.rb
adiwg-mdtranslator-1.4.0.beta2 lib/adiwg/mdtranslator/internal/module_coordinates.rb
adiwg-mdtranslator-1.4.0.beta1 lib/adiwg/mdtranslator/internal/module_coordinates.rb
adiwg-mdtranslator-1.3.0 lib/adiwg/mdtranslator/internal/module_coordinates.rb