Module: TicketNetwork::FormatHelper
- Included in:
- Base::Request, ParseHelper::ClassMethods
- Defined in:
- lib/ticket_network/format_helper.rb
Instance Method Summary collapse
-
#format_key(key, query = false) ⇒ Object
Formats keys for use in parsing responses and building query strings.
-
#format_query_key(key) ⇒ Object
Formats query keys for use in a query string.
-
#format_query_value(value) ⇒ Object
Formats and escapes query values for use in a query string.
Instance Method Details
#format_key(key, query = false) ⇒ Object
Formats keys for use in parsing responses and building query strings.
4 5 6 7 8 9 10 11 |
# File 'lib/ticket_network/format_helper.rb', line 4 def format_key(key, query=false) key = key.to_s key.upcase! if key == 'id' key.gsub!(/_id$/, '_ID') key.gsub!(/_url$/, '_URL') key = key.camelize(!query ? :upper : :lower) unless key == 'int' key end |
#format_query_key(key) ⇒ Object
Formats query keys for use in a query string.
14 15 16 |
# File 'lib/ticket_network/format_helper.rb', line 14 def format_query_key(key) format_key(key, true) end |
#format_query_value(value) ⇒ Object
Formats and escapes query values for use in a query string.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ticket_network/format_helper.rb', line 19 def format_query_value(value) value = case value when Time, Date value.to_s(:db) else value.to_s end CGI.escape(value) end |