Sha256: 0fbc2cb4e10ca39b76d60dd6d44b9996e09c923ab5446f98a3501bf833242123
Contents?: true
Size: 1.29 KB
Versions: 3
Compression:
Stored size: 1.29 KB
Contents
require 'pry' require 'vedeu/support/esc' require 'vedeu/models/colour' # Todo: style method (actually whole thing) module Vedeu module Helpers def line(&block) output = capture(&block) ERB.new(output.gsub(/\n/, ''), nil, '-').result(block.binding) end def foreground(value, &block) output = Esc.foreground_colour(value) if block_given? output << block.call output << Esc.string('fg_reset') end output end alias_method :fg, :foreground def background(value, &block) output = Esc.background_colour(value) if block_given? output << block.call output << Esc.string('bg_reset') end output end alias_method :bg, :background def colour(attributes = {}, &block) output = Colour.new(attributes).to_s if block_given? output << block.call output << Esc.string('colour_reset') end output end def style(*value_or_values, &block) if value_or_values.one? output = Esc.string(value_or_values.first) else output = value_or_values.map do |s| Esc.string(s) end.join end if block_given? output << block.call output << Esc.string('reset') end output end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.1.6 | lib/vedeu/support/helpers.rb |
vedeu-0.1.5 | lib/vedeu/support/helpers.rb |
vedeu-0.1.4 | lib/vedeu/support/helpers.rb |