Conversion for a number of internal data structures to and from directives in the headers. Implementations shouldn’t have to call any methods on Conversions.
Creates a string value from a boolean => ‘true’ or ‘false’
# File lib/httpauth/digest.rb, line 551 def bool_to_str(bool) bool ? 'true' : 'false' end
Create a list from a quoted comma separated string of items
# File lib/httpauth/digest.rb, line 570 def comma_quoted_string_to_list(string) unquote_string(string).split ',' end
Creates an int value from hex values
# File lib/httpauth/digest.rb, line 536 def hex_to_int(str) "0x#{str}".hex end
Creates a hex value in a string from an integer
# File lib/httpauth/digest.rb, line 541 def int_to_hex(i) i.to_s(16).rjust 8, '0' end
Creates a quoted string with comma separated items from a list
# File lib/httpauth/digest.rb, line 566 def list_to_comma_quoted_string(list) quote_string list.join(',') end
Creates a quoted string with space separated items from a list
# File lib/httpauth/digest.rb, line 556 def list_to_space_quoted_string(list) quote_string list.join(' ') end
Adds quotes around the string
# File lib/httpauth/digest.rb, line 526 def quote_string(str) "\"#{str.gsub(/\"/, '')}\"" end
Creates a list from a quoted space separated string of items
# File lib/httpauth/digest.rb, line 561 def space_quoted_string_to_list(string) unquote_string(string).split ' ' end
Creates a boolean value from a string => true or false
# File lib/httpauth/digest.rb, line 546 def str_to_bool(str) str == 'true' end
Removes quotes from around a string
# File lib/httpauth/digest.rb, line 531 def unquote_string(str) str =~ %r^\"([^\"]*)\"$/ ? $1 : str end