Class: HostsFile::File

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/hosts_file/file.rb

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ File

Returns a new instance of File.



8
9
10
# File 'lib/hosts_file/file.rb', line 8

def initialize(filename)
  @filename = filename
end

Instance Method Details

#each {|Host| ... } ⇒ Object

Yields:



23
24
25
26
27
# File 'lib/hosts_file/file.rb', line 23

def each(&block)
  parser.each do |host|
    yield(host)
  end
end

#hosts {|Host| ... } ⇒ Object

Yields:



14
15
16
17
18
19
20
# File 'lib/hosts_file/file.rb', line 14

def hosts(&block)
  if block_given?
    each(&block)
  else
    collect {|host| host}
  end
end