Class: MapDataExtractionUtil

Inherits:
Object
  • Object
show all
Defined in:
lib/whos_using_what/util/map_data_extraction_util.rb

Class Method Summary collapse

Class Method Details

.safe_extract_helper(keys_arr, map, doc_key, doc) ⇒ Object

doc_key = nil && doc=nil to return the end value instead of to add it to the doc



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/whos_using_what/util/map_data_extraction_util.rb', line 5

def self.safe_extract_helper keys_arr, map, doc_key, doc

  iter = 1
  val = ""
  keys_arr.each do |key|
    val = map[key]
    if !val
      return
    end
    if (iter == keys_arr.length)
      if doc
        doc[doc_key] = val
      end
    end
    iter = iter + 1
    map = val
  end
  val
end