Class: Viperaptor::Rambafile

Inherits:
Object
  • Object
show all
Defined in:
lib/viperaptor/helpers/rambafile.rb

Class Method Summary collapse

Class Method Details

.existObject



23
24
25
# File 'lib/viperaptor/helpers/rambafile.rb', line 23

def self.exist
  Dir[RAMBAFILE_NAME + "*"].count > 0
end

.rambafileObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/viperaptor/helpers/rambafile.rb', line 32

def self.rambafile

  if @@rambafile == nil

    if @@rambafile_name == nil

      files = Dir[RAMBAFILE_NAME + "*"]

      if files.count == 0
        puts("No Rambafile found".red)
        exit
      end

      if files.count == 1
        @@rambafile_name = files[0]
      else
        prompt = TTY::Prompt.new
        choices = files.sort
        @@rambafile_name = prompt.select("Select Rambafile?", choices, per_page: choices.count)
      end

    end

    if @@rambafile_name.start_with?(RAMBAFILE_NAME)
      @@rambafile_name_suffix = @@rambafile_name[RAMBAFILE_NAME.length..-1]
    else
      @@rambafile_name_suffix = "_" + @@rambafile_name
    end

    self.validate
    @@rambafile = YAML.load_file(@@rambafile_name)
    self.load_defaults
  end

  @@rambafile
end

.suffix(name) ⇒ Object



27
28
29
30
# File 'lib/viperaptor/helpers/rambafile.rb', line 27

def self.suffix(name)
  self.rambafile
  name + @@rambafile_name_suffix
end

.use(name) ⇒ Object



19
20
21
# File 'lib/viperaptor/helpers/rambafile.rb', line 19

def self.use(name)
  @@rambafile_name = name
end