Sha256: 1c9c8820d8505cb4abb9c7ea9c01199f3ba915c8d8e6294b53574849de5f0335

Contents?: true

Size: 668 Bytes

Versions: 1

Compression:

Stored size: 668 Bytes

Contents

class FortuneFinder
  class Record

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

    def exists?
      @exits ||= File.exists? file_path
    end

    def domain
      @domain ||= toml["domain"] if exists?
    end

    def name
      @name ||= toml["name"] if exists?
    end

    def rank
      @rank ||= toml["rank"] if exists?
    end

    def alias?
      @alias ||= File.symlink? file_path
    end
    alias_method :alias, :alias?

    private

    def file_path
      @file_path ||= File.expand_path "#{@raw_domain}.toml", FortuneFinder.domains_path
    end

    def toml
       @toml ||= TOML.load_file file_path
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fortune-finder-0.1.3 lib/fortune-finder/record.rb