module DocuBot::MetaSection::Castable
Public Instance Methods
as_boolean()
click to toggle source
# File lib/docubot/metasection.rb, line 4 def as_boolean self == 'true' end
as_list()
click to toggle source
# File lib/docubot/metasection.rb, line 7 def as_list return [] if self.nil? # Replace commas inside quoted strings with unlikely-to-be-used Unicode # FIXME: This doesnt work for the sadistic case of "hello """, "world" csv = self.gsub( /("(?:[^",]|"")+),/, '\\1⥸' ) csv.split(/\s*,\s*/).map do |str| # Put real commas back, unquote, undouble internal quotes str[/^".*"$/] ? str[1..-2].gsub('⥸',',').gsub('""','"') : str end end