Sha256: 95b6bdffcd8558ae44b32896b23a4def1578175c3ed4d9381d5840a630a45aa8
Contents?: true
Size: 998 Bytes
Versions: 2
Compression:
Stored size: 998 Bytes
Contents
# frozen_string_literal: true class ActWithFlags::Admin def to_s res = [] res << title("Variables") res << variables(:boolean_hash) res << variables(:delete_mask) res << blk("Flags sorted alfabetically") { |key, loc| "#{key} #{loc}" } res << blk("Flags and mask; sorted alfabetically") { |key, loc| "#{key} #{sprintf("0x%08X", mask(key))}" } res << blk("FLAG assignment; sorted alfabetically") { |key, loc| "FLAG_#{key.upcase} = #{sprintf("0x%08X", mask(key))}" } res << title("@locations") res << @locations res.flatten.join("\n") end private def title(msg) sep = "#" * 10 ["", "#{sep} #{msg} #{sep}"] end def blk(legend, &block) res = [title(legend)] sorted = @locations.sort sorted.each { |key, loc| res << block.call(key, loc) } res end def variables(*names) names.collect { |name| value = instance_variable_get(:"@#{name}") "#{name} #{value}" } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
act_with_flags-3.1.0 | lib/act_with_flags/print.rb |
act_with_flags-3.0.1 | lib/act_with_flags/print.rb |