Module: Xqsr3::StringUtilities::QuoteIf::QuoteIf_Helper_
- Defined in:
- lib/xqsr3/string_utilities/quote_if.rb
Overview
:nodoc:
Class Method Summary collapse
Class Method Details
.string_quote_if_array_(s, options) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/xqsr3/string_utilities/quote_if.rb', line 62 def self.string_quote_if_array_ s, s = s.to_s unless String === s quotes = [:quotes] || [ '"', '"' ] quotes = [ quotes, quotes ] if String === quotes quotables = [:quotables] || /\s/ case quotables when ::String return s unless s.include? quotables when ::Array return s unless quotables.any? { |quotable| s.include? quotable } when ::Regexp return s unless s =~ quotables else raise ArgumentError, "Invalid type (#{quotables.class}) specified for quotables parameter" end return quotes[0] + s + quotes[1] end |