[Ruby] Bit masking
\nclass CombinationIterator\n  def initialize(characters, combination_length)\n    @characters = characters\n    @combination_length = combination_length\n    @
```\nclass CombinationIterator\n  def initialize(characters, combination_length)\n    @characters = characters\n    @combination_length = combination_length\n    @length = characters.length\n    \n    bit_masking\n    \n    @current_index = @bit_combinations.count - 1\n  end\n\n  def next\n    combination = ""\n    \n    @length.times do |i|\n      if @bit_combinations[@current_index][i] != "0"\n        combination += @characters[i]\n      end\n    end\n    \n    @current_index -= 1\n    \n    combination\n  end\n\n  def has_next\n    @current_index > -1\n  end\n  \n  private\n  \n  def bit_masking\n    @bit_combinations = []\n  \n    (2**@length).times do |i|\n      bit_i = i.to_s(2)\n      if bit_i.count(\'1\') == @combination_length\n        @bit_combinations << bit_i.rjust(@length, "0")\n      end\n    end\n  end\nend\n```
['Ruby']