Module: AdWords::Utils
- Defined in:
- lib/adwords4r/utils.rb
Class Method Summary collapse
-
.get_map(entries) ⇒ Object
Gets a map from an array of map entries.
-
.operation_index_for_error(error) ⇒ Object
Returns the source operation index for an error.
Class Method Details
.get_map(entries) ⇒ Object
Gets a map from an array of map entries. A map entry is any object that has a key and value field.
Args:
-
entries: list of map entries
Returns:
-
hash constructed from map entries
37 38 39 40 41 42 43 |
# File 'lib/adwords4r/utils.rb', line 37 def self.get_map(entries) map = {} entries.each do |entry| map[entry.key] = entry.value end return map end |
.operation_index_for_error(error) ⇒ Object
Returns the source operation index for an error
Args:
-
error: the error to be analyzed
Returns:
-
index for the source operation, nil if none
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/adwords4r/utils.rb', line 53 def self.operation_index_for_error(error) if error and error.respond_to? :fieldPath and error.fieldPath parts = error.fieldPath.split('.') if parts.length > 0 match = parts.first.match(/operations\[(\d)\]/) return match ? match[1].to_i : nil end end return nil end |