Class: HostsFile::File
- Inherits:
-
Object
- Object
- HostsFile::File
- Includes:
- Enumerable
- Defined in:
- lib/hosts_file/file.rb
Instance Method Summary collapse
- #each {|Host| ... } ⇒ Object
- #hosts {|Host| ... } ⇒ Object
-
#initialize(filename) ⇒ File
constructor
A new instance of File.
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
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
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 |