Sha256: 3efebb4fd41082505010fc9dcf5d8cc272221e8eac3d1dec1b0b45a420c8fbc8
Contents?: true
Size: 602 Bytes
Versions: 3
Compression:
Stored size: 602 Bytes
Contents
require 'hosts_file/parser' require 'hosts_file/host' module HostsFile class File include Enumerable def initialize(filename) @filename = filename end # @yield {Host} # @return Array<Host> def hosts(&block) if block_given? each(&block) else collect {|host| host} end end # @yield {Host} def each(&block) parser.each do |host| yield(host) end end private def parser @hosts ||= Parser.new(raw_file) end def raw_file @raw_file ||= ::File.read(@filename) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hosts_file-1.0.3 | lib/hosts_file/file.rb |
hosts_file-0.0.2 | lib/hosts_file/file.rb |
hosts_file-0.0.1 | lib/hosts_file/file.rb |