Sha256: 57c580004742b373d000b0dab0f387d1971eafb0a1c937c9a06f98d2c7316852
Contents?: true
Size: 1.23 KB
Versions: 2
Compression:
Stored size: 1.23 KB
Contents
class Array def clean_string_values_in_array self.map! do |val| val.clean_string_values_in_array if val.is_a?(Array) val.clean_string_values_in_hash if val.is_a?(Hash) val.is_a?(String) ? val.strip.clean_string : val end end def to_ms_product_key valid_chars = 'BCDFGHJKMPQRTVWXY2346789'.scan(/./) product_key = nil raw_product_key = [] 52.upto(66) do |idx| raw_product_key << self[idx] end 24.downto(0) do |a| b = 0 14.downto(0) do |c| b = b * 256 ^ raw_product_key[c] raw_product_key[c] = (b / 24).to_i b = b.remainder(24) end product_key = "#{valid_chars[b]}#{product_key}" if a.remainder(5) == 0 && a != 0 product_key = "-#{product_key}" end end return product_key.upcase end def to_nil_hash h = Hash.new self.each do |item| if item.kind_of?(Hash) h.merge!(item) else h[item.to_sym] = nil end end return h end def to_wwn wwn = [] 0.upto(7) do |i| hex = self[i].to_s(16) hex = "0#{hex}" if self[i] < 16 wwn << hex end return wwn.join end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
boris-1.0.3 | lib/boris/core_ext/array.rb |
boris-1.0.2 | lib/boris/helpers/array.rb |