Class: Aro::Create

Inherits:
Object
  • Object
show all
Defined in:
lib/aro/create.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Create

Returns a new instance of Create.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/aro/create.rb', line 5

def initialize(name)
  self.initialized = false

  if !name.nil? && (
    name.kind_of?(String) ||
    name.kind_of?(Symbol)
  )
    # explicitly only allow String/Symbol types for name
    name = name.to_s.strip

    # create the new aro directory and database
    if Aro::Db.get_name_from_namefile.nil? && !Dir.exist?(name)
      Aro::P.say(I18n.t("cli.messages.no_decks"))
      create_cmd = "mkdir #{name}"
      Aro::P.say("#{create_cmd} (result: #{system(create_cmd)})")
    end

    # create database
    Aro::Db.new(name) 
    self.initialized = true       
  end
end

Instance Attribute Details

#initializedObject

Returns the value of attribute initialized.



3
4
5
# File 'lib/aro/create.rb', line 3

def initialized
  @initialized
end