Sha256: a5304f388b77651772fd1ae246ae601f95d12f34b8b5eecfc8d4be2781eb0dcc
Contents?: true
Size: 692 Bytes
Versions: 3
Compression:
Stored size: 692 Bytes
Contents
module Galakei class Spacer HEX = [ '47494638396101000100f70000', 'f'*1530, '2c000000000100010000080400010404003b' ] def initialize(color) @color = color.gsub('#','') end def create num = hex.size raise 'invalid hex' if num % 2 != 0 bin = '' (num/2).times do |i| bin += (hex[2 * (i + 1) - 2,2]).to_i(16).chr end return bin end def hex HEX[0] + @color + HEX[1] + HEX[2] end def img_tag(options = {}) width = options[:width] || '100%' height = options[:height] || 1 "<img src='/galakei/spacer/#{@color}' width='#{width}' height='#{height}'>" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
galakei-0.6.2 | lib/galakei/spacer.rb |
galakei-0.6.1 | lib/galakei/spacer.rb |
galakei-0.6.0 | lib/galakei/spacer.rb |