Method: Utilities#get_option

Defined in:
lib/utilities.rb

#get_option(options, key, default_value = "") ⇒ Object

Provides a simple failsafe for working with hash options returns “” if the option doesn’t exist or is blank

Attributes

  • options - the hash

  • key - key to find in options

  • default_value - if entered will be returned if the option doesn’t exist or is blank



136
137
138
139
140
# File 'lib/utilities.rb', line 136

def get_option(options, key, default_value = "")
  result = options.has_key?(key) ? options[key] : nil
  result = default_value if result.nil? || result == ""
  result
end