lib/maintain/bitmask_value.rb in maintain-0.2.23 vs lib/maintain/bitmask_value.rb in maintain-0.3.0

- old
+ new

@@ -2,11 +2,13 @@ module Maintain class BitmaskValue < Value include Enumerable def to_a - @state.states.select {|key, options| options[:value] & @value > 0}.map(&:first) + @state.states.select do |key, options| + options[:value] & @value > 0 + end.map(&:first) end def each(&block) to_a.each {|state| yield state } end @@ -20,10 +22,13 @@ @value = bitmask_for(value) end protected def bitmask_for(states) - Array(states).compact.map{|value| value_for(value) }.compact.sort.inject(0) {|total, mask| total | mask.to_i } + bitmask_values = Array(states).compact.map do |value| + value_for(value) + end.compact.sort + bitmask_values.inject(0) {|total, mask| total | mask.to_i } end def compare_value @value ||= 0 end