-
-
Save havenwood/d68f4235b38abbcd6dbb725a36a271f9 to your computer and use it in GitHub Desktop.
IRC example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require 'set' | |
module Abhijijt | |
SAFE = Set['gets', 'chomp', 'to_i', 'to_s'].freeze | |
module_function | |
def my_ui(prompt, input_type = nil) | |
puts prompt | |
input_type.split('.').grep(SAFE).reduce STDIN do |acc, meth| | |
acc.public_send meth | |
end | |
end | |
end | |
include Abhijijt | |
p my_ui('get my input', 'gets.to_i') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment