Module: Demode::Generate
- Defined in:
- lib/demode/generate.rb
Class Method Summary collapse
Class Method Details
.get(id, field) ⇒ Object
10 11 12 13 14 |
# File 'lib/demode/generate.rb', line 10 def get(id, field) if Generator.respond_to? field return Generator.send(field, normalize_id(id)) end end |
.normalize_id(id) ⇒ Object
16 17 18 |
# File 'lib/demode/generate.rb', line 16 def normalize_id(id) Digest::MD5.hexdigest( sigflat id ).hex end |
.sigflat(id) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/demode/generate.rb', line 20 def sigflat(id) if id.class == Hash arr = [] id.each do |key, value| arr << "#{sigflat key}=>#{sigflat value}" end id = arr end if id.class == Array str = '' id.map! do |value| sigflat value end.sort!.each do |value| str << value end end if id.class != String id = id.to_s << id.class.to_s end id end |