Class: Array
Instance Method Summary
collapse
Methods included from ForceArray
#force_array, #force_array!
Instance Method Details
#concatenate_property_instances(property = String) ⇒ Object
1312
1313
1314
1315
1316
1317
1318
1319
|
# File 'lib/liquidoc.rb', line 1312
def concatenate_property_instances property=String
all_arrays = []
self.each do |i|
all_arrays << i[property]
end
return all_arrays.flatten
end
|
#repeated_property_values(property = String) ⇒ Object
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
|
# File 'lib/liquidoc.rb', line 1321
def repeated_property_values property=String
firsts = []
dupes = []
self.each do |node|
return ['non-array property value present'] unless node[property].is_a? Array
node[property].each do |i|
dupes << i if firsts.include? i
firsts << i
end
end
return dupes
end
|
#to_hash ⇒ Object
1292
1293
1294
1295
1296
1297
1298
|
# File 'lib/liquidoc.rb', line 1292
def to_hash
struct = {}
self.each do |p|
struct.merge!p if p.is_a? Hash
end
return struct
end
|
#unique_property_values(property = nil) ⇒ Object
Get all unique values for each item in an array, or each unique value of a desigated
parameter in an array of hashes.
1305
1306
1307
1308
1309
1310
|
# File 'lib/liquidoc.rb', line 1305
def unique_property_values property=nil
return self.uniq unless property
new_ary = self.uniq { |i| i[property] }
out = new_ary.map { |i| i[property] }.compact
out
end
|