Class: Umu::Inputter

Inherits:
Object
  • Object
show all
Extended by:
Template
Defined in:
lib/umu/core/inputter.rb

Constant Summary

Constants included from Color

Color::COLORS

Class Method Summary collapse

Methods included from Template

checker, cover, hover, pointer

Class Method Details

.input(content, has_vaild = false, check_target = []) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/umu/core/inputter.rb', line 9

def self.input(content, has_vaild = false, check_target = [])
  puts content.to_s
  input_val = gets
  is_empty = input_val.chomp == ''
  while is_empty
    cover(2)
    puts "\e[1A"
    puts "#{content} #{red('必須項目です')}"
    input_val = gets
    is_empty = input_val.chomp == ''
  end

  if has_vaild
    is_overlap = Umu::Validation.check_overlap(check_target, input_val.chomp)
    while is_overlap
      cover(2)
      puts "\e[1A"
      puts "#{content} #{red("#{input_val.chomp}は重複です")}"
      input_val = gets

      is_empty = input_val.chomp == ''
      while is_empty
        cover(2)
        puts "\e[1A"
        puts "#{content} #{red('必須項目です')}"
        input_val = gets
        is_empty = input_val.chomp == ''
      end

      is_overlap = Umu::Validation.check_overlap(check_target, input_val.chomp)
    end
  end
  puts "\e[2A"
  input_val.chomp
end