Method: GoodData::SmallGoodZilla.extract_element_uri_pairs

Defined in:
lib/gooddata/goodzilla/goodzilla.rb

.extract_element_uri_pairs(maql) ⇒ Array<Array>

Scans the provided MAQL and returns Array pairs of [attribute, element] pairs for each element that is found in the definition

Parameters:

  • maql

    Input MAQL string

Returns:

  • (Array<Array>)

    Pairs [attribute, attribute_element]



13
14
15
16
17
18
# File 'lib/gooddata/goodzilla/goodzilla.rb', line 13

def extract_element_uri_pairs(maql)
  arr = maql.scan(%r{(\/gdc\/(?:projects|md)\/[a-zA-Z\d]+\/obj\/\d+)\/elements\?id=(\d+)}).flatten
  evens = arr.select.each_with_index { |_, i| i.even? }
  odds = arr.select.each_with_index { |_, i| i.odd? }.map(&:to_i)
  evens.zip(odds)
end