Class: Module

Inherits:
Object show all
Defined in:
lib/ragweed/utils.rb

Instance Method Summary collapse

Instance Method Details

#flag_dump(i) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/ragweed/utils.rb', line 67

def flag_dump(i)
  @bit_map ||= constants.map do |k|
    [k, const_get(k.intern).ffs]
  end.sort {|x, y| x[1] <=> y[1]}

  last = 0
  r = ""
  @bit_map.each do |tup|
    if((v = (tup[1] - last)) > 1)
      r << ("." * (v-1))
    end

    if((i & (1 << tup[1])) != 0)
      r << tup[0][0].chr
    else
      r << tup[0][0].chr.downcase
    end
    last = tup[1]
  end
  return r.reverse
end