class Array

Public Instance Methods

json_data_for_highcharts() click to toggle source
# File lib/marskal/core/extensions/array.rb, line 17
def json_data_for_highcharts
  # self.to_json.gsub(/[\'\"]/,'')   #maybe add this as a parameter to include or exclude single quotes
  self.to_json.gsub(/[\"]/,'')       # but for now, we will allow single quotes a strings are allowed in json
end
prepare_for_sql_in_clause() click to toggle source
# File lib/marskal/core/extensions/array.rb, line 13
def prepare_for_sql_in_clause
  "(#{self.to_string_no_brackets})"
end
sql_null_to_blank() click to toggle source
# File lib/marskal/core/extensions/array.rb, line 22
def sql_null_to_blank
  self.map {|v| "IFNULL(#{v}, '')" }
end
to_string_no_brackets() click to toggle source

converts an array to a string and strips outer brackets ex: [1,2,3].to_string_no_brackets ==> returns “1,2,3”

# File lib/marskal/core/extensions/array.rb, line 4
def to_string_no_brackets
  self.to_s.gsub(/[\[\]]/,'')
end
to_string_no_brackets_or_quotes() click to toggle source
# File lib/marskal/core/extensions/array.rb, line 8
def to_string_no_brackets_or_quotes #addded sept 204 when using for datatables jquery plugin, but can be used for anything
  self.to_s.gsub(/[\"\[\]]/,'')     #convert an array into a string and remove the quotes Originally developed to help 'pluck'
end