Module: ForceArray
Overview
Text manipulation Classes, Modules, procs, etc
Instance Method Summary collapse
-
#force_array ⇒ Object
So we can accept a list string (“item1.yml,item2.yml”) or a single item (“item1.yml”) and convert to array as needed.
- #force_array! ⇒ Object
Instance Method Details
#force_array ⇒ Object
So we can accept a list string (“item1.yml,item2.yml”) or a single item (“item1.yml”) and convert to array as needed
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 |
# File 'lib/liquidoc.rb', line 1207 def force_array obj = self unless obj.class == Array if obj.class == String if obj.include? "," obj = obj.split(",") # Will even force a string with no commas to a 1-item array else obj = Array.new.push(obj) end else if obj.class == Hash obj = obj.to_array else raise "ForceArrayFail" end end end return obj.to_ary end |
#force_array! ⇒ Object
1227 1228 1229 |
# File 'lib/liquidoc.rb', line 1227 def force_array! self.force_array end |