Sha256: 95472f3296d5670827009f64cbe22c7454f47a2707a712249c6487d3229f5106
Contents?: true
Size: 587 Bytes
Versions: 5
Compression:
Stored size: 587 Bytes
Contents
# encoding: UTF-8 require "polygonize/version" module Polygonize String.class_eval do def coordinates ar1 = [] ar2 = [] self.split(//).each do | char | u = format("%x", char.unpack("U*")[0]) ar1 << u.scan(/../) end # 奇数の場合は "00" を追加して、偶数配列にする ar1.flatten! ar1 << "00" if ar1.flatten.size%2 == 1 # Max 255 で座標の文字列を生成 ar1.each_slice(2) do | a,b | ar2 << [a, b].map! { |c| c.hex }.join(",") end ar2.join(" ") end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
polygonize-0.0.7 | lib/polygonize.rb |
polygonize-0.0.6 | lib/polygonize.rb |
polygonize-0.0.5 | lib/polygonize.rb |
polygonize-0.0.4 | lib/polygonize.rb |
polygonize-0.0.3 | lib/polygonize.rb |