Sha256: 22b0ea2ae3c10cd7511ee430fee9da59ca5f0e82db5ab138fc6584b13bee5fe1
Contents?: true
Size: 747 Bytes
Versions: 1
Compression:
Stored size: 747 Bytes
Contents
module MakeMenu class BadgeSet def initialize @badges = [] end def display rows = [] row = '' @badges.each do |badge| label = badge[:label] value = badge[:handler].call ? badge[:on] : badge[:off] if row.decolor.size + label.decolor.size + value.decolor.size >= (0.7 * ::TTY::Screen.cols) rows << row row = '' end row += " #{label}#{value} " end rows << row puts rows.join("\n\n").align_block(:center) puts end def add(label = '', on: ' ON '.green_bg.bold, off: ' OFF '.red_bg.dark, &block) @badges << { label: label, on: on, off: off, handler: block } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
make_menu-1.1.0 | lib/make_menu/badge_set.rb |