Class: HTTPAuth::Digest::Conversions
- Inherits:
-
Object
- Object
- HTTPAuth::Digest::Conversions
- Defined in:
- lib/httpauth/digest.rb
Overview
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.
Class Method Summary collapse
-
.bool_to_str(bool) ⇒ Object
Creates a string value from a boolean => ‘true’ or ‘false’.
-
.comma_quoted_string_to_list(string) ⇒ Object
Create a list from a quoted comma separated string of items.
-
.hex_to_int(str) ⇒ Object
Creates an int value from hex values.
-
.int_to_hex(i) ⇒ Object
Creates a hex value in a string from an integer.
-
.list_to_comma_quoted_string(list) ⇒ Object
Creates a quoted string with comma separated items from a list.
-
.list_to_space_quoted_string(list) ⇒ Object
Creates a quoted string with space separated items from a list.
-
.quote_string(str) ⇒ Object
Adds quotes around the string.
-
.space_quoted_string_to_list(string) ⇒ Object
Creates a list from a quoted space separated string of items.
-
.str_to_bool(str) ⇒ Object
Creates a boolean value from a string => true or false.
-
.unquote_string(str) ⇒ Object
Removes quotes from around a string.
Class Method Details
.bool_to_str(bool) ⇒ Object
Creates a string value from a boolean => ‘true’ or ‘false’
551 552 553 |
# File 'lib/httpauth/digest.rb', line 551 def bool_to_str(bool) bool ? 'true' : 'false' end |
.comma_quoted_string_to_list(string) ⇒ Object
Create a list from a quoted comma separated string of items
570 571 572 |
# File 'lib/httpauth/digest.rb', line 570 def comma_quoted_string_to_list(string) unquote_string(string).split ',' end |
.hex_to_int(str) ⇒ Object
Creates an int value from hex values
536 537 538 |
# File 'lib/httpauth/digest.rb', line 536 def hex_to_int(str) "0x#{str}".hex end |
.int_to_hex(i) ⇒ Object
Creates a hex value in a string from an integer
541 542 543 |
# File 'lib/httpauth/digest.rb', line 541 def int_to_hex(i) i.to_s(16).rjust 8, '0' end |
.list_to_comma_quoted_string(list) ⇒ Object
Creates a quoted string with comma separated items from a list
566 567 568 |
# File 'lib/httpauth/digest.rb', line 566 def list_to_comma_quoted_string(list) quote_string list.join(',') end |
.list_to_space_quoted_string(list) ⇒ Object
Creates a quoted string with space separated items from a list
556 557 558 |
# File 'lib/httpauth/digest.rb', line 556 def list_to_space_quoted_string(list) quote_string list.join(' ') end |
.quote_string(str) ⇒ Object
Adds quotes around the string
526 527 528 |
# File 'lib/httpauth/digest.rb', line 526 def quote_string(str) "\"#{str.gsub(/\"/, '')}\"" end |
.space_quoted_string_to_list(string) ⇒ Object
Creates a list from a quoted space separated string of items
561 562 563 |
# File 'lib/httpauth/digest.rb', line 561 def space_quoted_string_to_list(string) unquote_string(string).split ' ' end |
.str_to_bool(str) ⇒ Object
Creates a boolean value from a string => true or false
546 547 548 |
# File 'lib/httpauth/digest.rb', line 546 def str_to_bool(str) str == 'true' end |
.unquote_string(str) ⇒ Object
Removes quotes from around a string
531 532 533 |
# File 'lib/httpauth/digest.rb', line 531 def unquote_string(str) str =~ /^\"([^\"]*)\"$/ ? $1 : str end |