Skip to content

Instantly share code, notes, and snippets.

@havenwood
Last active December 15, 2019 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havenwood/d68f4235b38abbcd6dbb725a36a271f9 to your computer and use it in GitHub Desktop.
Save havenwood/d68f4235b38abbcd6dbb725a36a271f9 to your computer and use it in GitHub Desktop.
IRC example
# 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