Sha256: bcf65b782d673b64d6aad317e69d71a9c9947c2f325fa9bb8bae3cb592f656be

Contents?: true

Size: 438 Bytes

Versions: 3

Compression:

Stored size: 438 Bytes

Contents

# frozen_string_literal: true

require "yaml"

module RogueOne
  class DomainList
    attr_reader :path

    def initialize(path)
      @path = path.to_s
    end

    def valid?
      exists? && valid_format?
    end

    def domains
      @domains ||= exists? ? YAML.safe_load(File.read(path)) : nil
    end

    private

    def exists?
      File.exist?(path)
    end

    def valid_format?
      domains.is_a? Array
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rogue_one-0.4.0 lib/rogue_one/domain_list.rb
rogue_one-0.3.0 lib/rogue_one/domain_list.rb
rogue_one-0.2.0 lib/rogue_one/domain_list.rb