Class: Picobox::Shell::IniFile

Inherits:
Object
  • Object
show all
Defined in:
lib/picobox/shell/ini_file.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(os) ⇒ IniFile

Returns a new instance of IniFile.



10
11
12
# File 'lib/picobox/shell/ini_file.rb', line 10

def initialize(os)
  @os = os
end

Class Method Details

.get(os) ⇒ Object



5
6
7
# File 'lib/picobox/shell/ini_file.rb', line 5

def get(os)
  self.new(os)
end

Instance Method Details

#[](key) ⇒ Object



21
22
23
# File 'lib/picobox/shell/ini_file.rb', line 21

def [](key)
  ini_file[key]
end

#[]=(section, value) ⇒ Object



26
27
28
29
# File 'lib/picobox/shell/ini_file.rb', line 26

def []=(section, value)
  ini_file[section.to_s] = value
  ini_file.save
end

#installObject



14
15
16
17
18
# File 'lib/picobox/shell/ini_file.rb', line 14

def install
  TTY::File.create_file filename do |content|
    "[packages]\nversion=v0.0\nlast_update=#{Time.now.to_i}\n"
  end unless File.exist? filename
end