Class: Front::CLI::Frontfile
- Inherits:
-
Object
- Object
- Front::CLI::Frontfile
- Defined in:
- lib/front/cli/front_file.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #create(defaults) ⇒ Object
- #exists? ⇒ Boolean
- #get_current_id ⇒ Object
- #get_pool_size ⇒ Object
-
#initialize(path) ⇒ Frontfile
constructor
A new instance of Frontfile.
- #load ⇒ Object
- #save ⇒ Object
- #set_current_id(current_id) ⇒ Object
- #set_pool_size(pool_size) ⇒ Object
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
#data ⇒ Object (readonly)
Returns the value of attribute data.
7 8 9 |
# File 'lib/front/cli/front_file.rb', line 7 def data @data end |
#path ⇒ Object (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
13 14 15 |
# File 'lib/front/cli/front_file.rb', line 13 def exists? File.exists?(path) end |
#get_current_id ⇒ Object
34 35 36 |
# File 'lib/front/cli/front_file.rb', line 34 def get_current_id @data['current_id'] end |
#get_pool_size ⇒ Object
42 43 44 |
# File 'lib/front/cli/front_file.rb', line 42 def get_pool_size @data['pool_size'] end |
#load ⇒ Object
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 |
#save ⇒ Object
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 |