Sha256: aa187620fee65ff009493967c922e0a3bf49dc83a10350d73ad1047ac77fdf07
Contents?: true
Size: 1.04 KB
Versions: 6
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true module MakeMenu # This class represents an option in the menu which runs a target from the Makefile class MenuItem INDENT = 6 def initialize(option_number = nil, target = nil, description = nil) @option_number = option_number @target = target @description = description || target end attr_reader :option_number, :target, :description def execute cmd = ['make', target] puts "> #{cmd.join(' ').cyan}\n" unless system(*cmd) # Indicates the command failed, so we pause to allow user to see error message puts "\nPress ENTER to continue....".dark gets end rescue StandardError => _e # Sink keyboard interrupt from within Make target end # @return [Integer] Number of characters required to display the item def width description.size + INDENT + 1 end # @return [String] Text to display for this item def to_s "#{option_number.to_s.rjust(INDENT, ' ').bold}. #{description}" end end end
Version data entries
6 entries across 6 versions & 1 rubygems