Class: EtcHosts

Inherits:
Object
  • Object
show all
Includes:
CommentParser, FileReader
Defined in:
lib/resources/etc_hosts.rb

Constant Summary collapse

DEFAULT_UNIX_PATH =
'/etc/hosts'.freeze
DEFAULT_WINDOWS_PATH =
'C:\windows\system32\drivers\etc\hosts'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FileReader

#read_file_content

Methods included from CommentParser

#parse_comment_line

Constructor Details

#initialize(hosts_path = nil) ⇒ EtcHosts

Returns a new instance of EtcHosts.



29
30
31
32
33
# File 'lib/resources/etc_hosts.rb', line 29

def initialize(hosts_path = nil)
  content = read_file_content(hosts_path || default_hosts_file_path)

  @params = parse_conf(content.lines)
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



21
22
23
# File 'lib/resources/etc_hosts.rb', line 21

def params
  @params
end