Module: URITemplate::RFC6570::Utils

Extended by:
Utils
Includes:
Utils
Included in:
Utils
Defined in:
lib/uri_template/rfc6570.rb

Constant Summary

Constants included from Utils

Utils::KCODE_UTF8

Constants included from Utils::Escaping::Pure

Utils::Escaping::Pure::PCT, Utils::Escaping::Pure::URI_ESCAPED, Utils::Escaping::Pure::URL_ESCAPED

Instance Method Summary collapse

Methods included from Utils

#compact_regexp, #object_to_param, #pair_array?, #pair_array_to_hash, #pair_array_to_hash2, #use_unicode?

Methods included from Utils::Escaping::Pure

#escape_uri, #escape_url, #unescape_uri, #unescape_url, #using_escape_utils?

Methods included from Utils::Escaping::EscapeUtils

#escape_uri, #escape_url, #unescape_uri, #unescape_url, #using_escape_utils?

Methods included from Utils::StringEncoding::Fallback

#force_utf8, #to_ascii, #to_utf8

Methods included from Utils::StringEncoding::Encode

#force_utf8, #to_ascii, #to_utf8

Instance Method Details

#def?(value) ⇒ Boolean

Returns true iff the value is ‘defined` [RFC6570 Section 2.3](tools.ietf.org/html/rfc6570#section-2.3)

The only undefined things are:

  • nil

  • arrays containing no defined value

  • associative arrays/hashes containing no defined value

Things that are always defined:

  • Strings, independent of the length

Returns:

  • (Boolean)


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/uri_template/rfc6570.rb', line 55

def def?( value )
  case( value )
  when nil  then
    false
  when Hash then
    value.any?{|_, v| !v.nil? }
  when Array then
    if value.none?
      false
    elsif value[0].kind_of?(Array)
      value.any?{|_,v| !v.nil? }
    else
      value.any?{|v| !v.nil? }
    end
  else
    true
  end
end