Class: Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/command/settings.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSettings

Returns a new instance of Settings.



4
5
6
# File 'lib/command/settings.rb', line 4

def initialize
  @key, @secret, @host = parse_settings
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



2
3
4
# File 'lib/command/settings.rb', line 2

def host
  @host
end

#keyObject (readonly)

Returns the value of attribute key.



2
3
4
# File 'lib/command/settings.rb', line 2

def key
  @key
end

#secretObject (readonly)

Returns the value of attribute secret.



2
3
4
# File 'lib/command/settings.rb', line 2

def secret
  @secret
end

Instance Method Details

#directoryObject



8
9
10
# File 'lib/command/settings.rb', line 8

def directory
  File.join home_directory, 'MyFDB_Uploads'
end

#fileObject



12
13
14
# File 'lib/command/settings.rb', line 12

def file
  "#{ENV['HOME']}/.myfdb"
end

#home_directoryObject



20
21
22
# File 'lib/command/settings.rb', line 20

def home_directory
  running_on_windows? ? ENV['USERPROFILE'] : ENV['HOME']
end

#parse_settingsObject



16
17
18
# File 'lib/command/settings.rb', line 16

def parse_settings
  File.read(file).split('|')
end

#running_on_windows?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/command/settings.rb', line 24

def running_on_windows?
  RUBY_PLATFORM =~ /mswin32|mingw32/
end