Module: Rubeetup::Utilities
- Included in:
- MeetupCatalog, Request, RequestResponse, RequestSender, Requester
- Defined in:
- lib/rubeetup/utilities.rb
Overview
Provides some miscellaneous methods for mix-ins
Instance Method Summary collapse
-
#blank?(obj) ⇒ Boolean
Whether the object is blank as per Ruby Active Support.
-
#collection_symbolyzer(array) ⇒ Array<Symbol, Array...>
Transforms the strings into a possibly nested collection, into symbols.
-
#present?(obj) ⇒ Boolean
Determines if the object is not blank (see #blank?).
-
#stringify(options) ⇒ String
Generates a string of key values to include in URL’s.
Instance Method Details
#blank?(obj) ⇒ Boolean
Returns whether the object is blank as per Ruby Active Support.
18 19 20 |
# File 'lib/rubeetup/utilities.rb', line 18 def blank?(obj) obj.nil? || obj == false || obj.empty? || obj =~ /^\s+$/ end |
#collection_symbolyzer(array) ⇒ Array<Symbol, Array...>
Note:
For speed and simplicity no error checking is performed
Transforms the strings into a possibly nested collection, into symbols
38 39 40 |
# File 'lib/rubeetup/utilities.rb', line 38 def collection_symbolyzer(array) array.map {|elem| elem.is_a?(String) ? elem.to_sym : collection_symbolyzer(elem)} end |
#present?(obj) ⇒ Boolean
Determines if the object is not blank (see #blank?)
10 11 12 |
# File 'lib/rubeetup/utilities.rb', line 10 def present?(obj) !blank?(obj) end |
#stringify(options) ⇒ String
Generates a string of key values to include in URL’s
27 28 29 30 |
# File 'lib/rubeetup/utilities.rb', line 27 def stringify() return '' unless .respond_to? :map .map { |key, val| "#{key}=#{val}" if key && val }.compact.join('&') end |