class HTTPAuth::Digest::Conversions

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.

Public Class Methods

bool_to_str(bool) click to toggle source

Creates a string value from a boolean => ‘true’ or ‘false’

# File lib/httpauth/digest.rb, line 552
def bool_to_str(bool)
  bool ? 'true' : 'false'
end
comma_quoted_string_to_list(string) click to toggle source

Create a list from a quoted comma separated string of items

# File lib/httpauth/digest.rb, line 571
def comma_quoted_string_to_list(string)
  unquote_string(string).split ','
end
hex_to_int(str) click to toggle source

Creates an int value from hex values

# File lib/httpauth/digest.rb, line 537
def hex_to_int(str)
  "0x#{str}".hex
end
int_to_hex(i) click to toggle source

Creates a hex value in a string from an integer

# File lib/httpauth/digest.rb, line 542
def int_to_hex(i)
  i.to_s(16).rjust 8, '0'
end
list_to_comma_quoted_string(list) click to toggle source

Creates a quoted string with comma separated items from a list

# File lib/httpauth/digest.rb, line 567
def list_to_comma_quoted_string(list)
  quote_string list.join(',')
end
list_to_space_quoted_string(list) click to toggle source

Creates a quoted string with space separated items from a list

# File lib/httpauth/digest.rb, line 557
def list_to_space_quoted_string(list)
  quote_string list.join(' ')
end
quote_string(str) click to toggle source

Adds quotes around the string

# File lib/httpauth/digest.rb, line 527
def quote_string(str)
  "\"#{str.gsub(/\"/, '')}\""
end
space_quoted_string_to_list(string) click to toggle source

Creates a list from a quoted space separated string of items

# File lib/httpauth/digest.rb, line 562
def space_quoted_string_to_list(string)
  unquote_string(string).split ' '
end
str_to_bool(str) click to toggle source

Creates a boolean value from a string => true or false

# File lib/httpauth/digest.rb, line 547
def str_to_bool(str)
  str == 'true'
end
unquote_string(str) click to toggle source

Removes quotes from around a string

# File lib/httpauth/digest.rb, line 532
def unquote_string(str)
  str =~ /^\"([^\"]*)\"$/ ? Regexp.last_match[1] : str
end