class Logchange::InteractiveLogger
Accept change information from the user via command line prompts.
Public Class Methods
new()
click to toggle source
# File lib/logchange/interactive_logger.rb, line 6 def initialize @title = nil @template = {} end
Public Instance Methods
execute()
click to toggle source
# File lib/logchange/interactive_logger.rb, line 11 def execute input_title template = Logchange::Template.load template.each do |key, value| input(key, value) end Logchange::Logger.new(@title, template: @template).execute end
Private Instance Methods
input(key, value)
click to toggle source
# File lib/logchange/interactive_logger.rb, line 37 def input(key, value) puts "#{key}: #{value}" user_input = STDIN.gets.chomp if user_input.length.positive? # Preserve booleans. if %w[true false].include?(user_input) user_input = (user_input == 'true') end @template[key] = user_input end puts "\n" end
input_title()
click to toggle source
# File lib/logchange/interactive_logger.rb, line 25 def input_title while @title.nil? print 'title: ' @title = STDIN.gets.chomp if @title.length.zero? puts "Title cannot be blank.\n\n" @title = nil end end end