Class: Front::CLI::Frontfile

Inherits:
Object
  • Object
show all
Defined in:
lib/front/cli/front_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Frontfile

Returns a new instance of Frontfile.



9
10
11
# File 'lib/front/cli/front_file.rb', line 9

def initialize(path)
  @path = path
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



7
8
9
# File 'lib/front/cli/front_file.rb', line 7

def data
  @data
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/front/cli/front_file.rb', line 6

def path
  @path
end

Instance Method Details

#create(defaults) ⇒ Object



17
18
19
20
# File 'lib/front/cli/front_file.rb', line 17

def create(defaults)
  @data = defaults
  save()
end

#exists?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/front/cli/front_file.rb', line 13

def exists?
  File.exists?(path)
end

#get_current_idObject



34
35
36
# File 'lib/front/cli/front_file.rb', line 34

def get_current_id
  @data['current_id']
end

#get_pool_sizeObject



42
43
44
# File 'lib/front/cli/front_file.rb', line 42

def get_pool_size
  @data['pool_size']
end

#loadObject



22
23
24
25
# File 'lib/front/cli/front_file.rb', line 22

def load
  file_contents = File.read(path)
  @data = JSON.parse(file_contents)
end

#saveObject



27
28
29
30
31
32
# File 'lib/front/cli/front_file.rb', line 27

def save
  json = @data.to_json
  File.open(path, 'w') do |file|
    file.write(json)
  end
end

#set_current_id(current_id) ⇒ Object



38
39
40
# File 'lib/front/cli/front_file.rb', line 38

def set_current_id(current_id)
  @data['current_id'] = current_id
end

#set_pool_size(pool_size) ⇒ Object



46
47
48
# File 'lib/front/cli/front_file.rb', line 46

def set_pool_size(pool_size)
  @data['pool_size'] = pool_size
end