lib/haiti.rb in haiti-hash-1.5.0 vs lib/haiti.rb in haiti-hash-2.0.0

- old
+ new

@@ -48,9 +48,28 @@ end end samples.delete(nil) samples.flatten.uniq end + + # List names of all hash types available + # @return [Array<String>] a list of hash types name + # @example + # HashIdentifier.list + # # => ["CRC-16", "CRC-16-CCITT", "FCS-16", "Adler-32", "CRC-32B", "FCS-32", ...] + def list + (PROTOTYPES.flat_map { |d| d['modes'].map { |m| m['name'] } }).sort { |a, b| a.downcase <=> b.downcase }.uniq + end + + # List all hash types available as <Chf> object + # @return [Array<Chf>] a list of hash types object + def object_list + (PROTOTYPES.flat_map do |d| + d['modes'].map do |m| + Chf.new(m) + end + end).sort { |a, b| a.name.downcase <=> b.name.downcase }.uniq + end end private # Check which hash types are matching the provided hash