Module: ForceArray

Included in:
Array, String
Defined in:
lib/liquidoc.rb

Instance Method Summary collapse

Instance Method Details

#force_arrayObject

So we can accept a list string (“item1.yml,item2.yml”) or a single item (“item1.yml”) and convert to array as needed



1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
# File 'lib/liquidoc.rb', line 1024

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
      raise "ForceArrayFail"
    end
  end
  return obj.to_ary
end