Class: Hutils::Ltap::Conf

Inherits:
Object
  • Object
show all
Defined in:
lib/hutils/ltap/conf.rb

Defined Under Namespace

Classes: SectionNotFound

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConf

Returns a new instance of Conf.



14
15
16
17
18
19
20
# File 'lib/hutils/ltap/conf.rb', line 14

def initialize
  @ini = IniFile.load(ENV["HOME"] + "/.ltap")
  self.earliest = "-24h"
  self.timeout = 60
  self.timestamps = false
  self.verbose = false
end

Instance Attribute Details

#earliestObject

Returns the value of attribute earliest.



5
6
7
# File 'lib/hutils/ltap/conf.rb', line 5

def earliest
  @earliest
end

#keyObject

Returns the value of attribute key.



6
7
8
# File 'lib/hutils/ltap/conf.rb', line 6

def key
  @key
end

#profileObject

Returns the value of attribute profile.



7
8
9
# File 'lib/hutils/ltap/conf.rb', line 7

def profile
  @profile
end

#timeoutObject

Returns the value of attribute timeout.



8
9
10
# File 'lib/hutils/ltap/conf.rb', line 8

def timeout
  @timeout
end

#timestampsObject

Returns the value of attribute timestamps.



9
10
11
# File 'lib/hutils/ltap/conf.rb', line 9

def timestamps
  @timestamps
end

#typeObject

Returns the value of attribute type.



10
11
12
# File 'lib/hutils/ltap/conf.rb', line 10

def type
  @type
end

#urlObject

Returns the value of attribute url.



11
12
13
# File 'lib/hutils/ltap/conf.rb', line 11

def url
  @url
end

#verboseObject

Returns the value of attribute verbose.



12
13
14
# File 'lib/hutils/ltap/conf.rb', line 12

def verbose
  @verbose
end

Instance Method Details

#loadObject



22
23
24
# File 'lib/hutils/ltap/conf.rb', line 22

def load
  load_section("global")
end

#load_section(name) ⇒ Object

Raises:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/hutils/ltap/conf.rb', line 26

def load_section(name)
  return unless @ini
  raise SectionNotFound unless @ini.has_section?(name)

  section = @ini[name]
  load_value(section, :earliest)
  load_value(section, :key)
  load_value(section, :profile)
  load_value(section, :timeout)
  load_value(section, :timestamps)
  load_value(section, :type)
  load_value(section, :url)
  load_value(section, :verbose)
end