Class: Generator::AcceptInput

Inherits:
Object
  • Object
show all
Defined in:
lib/ngi/generator.rb

Overview

STDIN is separated into a class so that it can be extracted and tested

Class Method Summary collapse

Class Method Details

.str(type) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/ngi/generator.rb', line 13

def self.str(type)
  case type
  when :condensed
    $stdin.gets.gsub(WHITESPACE, EMPTY)
  when :comma_delimited_to_array
    $stdin.gets.split(',').map(&:strip).reject(&:empty?)
  when :downcased
    $stdin.gets.strip.downcase
  end
end