Class: Lazyman::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/lazyman/lazy_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filepath) ⇒ Config

Returns a new instance of Config.



9
10
11
12
13
# File 'lib/lazyman/lazy_config.rb', line 9

def initialize filepath
	@f ||= filepath if valid?(filepath)
	File.open(@f) {|handle| @hash_content = YAML.load(handle)}
	@content = OpenStruct.new(@hash_content)
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



7
8
9
# File 'lib/lazyman/lazy_config.rb', line 7

def content
  @content
end

#hash_contentObject (readonly)

Returns the value of attribute hash_content.



7
8
9
# File 'lib/lazyman/lazy_config.rb', line 7

def hash_content
  @hash_content
end

Instance Method Details

#valid?(filepath) ⇒ Boolean

Returns:

  • (Boolean)

Raises:



15
16
17
18
# File 'lib/lazyman/lazy_config.rb', line 15

def valid?(filepath)
	raise ConfigFileMissingError unless File.exists?(filepath)
	true
end