Class: Ucode::Fetch::FontFetcher::Result

Inherits:
Struct
  • Object
show all
Defined in:
lib/ucode/fetch/font_fetcher/result.rb

Overview

Typed outcome of fetching one font. The fetcher never raises for a single font failure; it returns a :failed Result so the aggregate run can keep going and report every problem.

Statuses:

  • :downloaded — fetched this run; bytes are on disk at path.
  • :skipped — already present with matching SHA256 (or dry-run).
  • :failed — license refused, checksum mismatch, network error, or zip extraction error. error is set.
  • :localurl: null; the user supplies the file. May or may not be present yet (see note).
  • :planned — dry-run only; this entry would have been fetched.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, **opts) ⇒ Result

Returns a new instance of Result.



23
24
25
26
27
28
29
# File 'lib/ucode/fetch/font_fetcher/result.rb', line 23

def initialize(status:, **opts)
  unless STATUSES.include?(status)
    raise ArgumentError, "unknown FontFetcher::Result status: #{status.inspect}"
  end

  super
end

Instance Attribute Details

#errorObject

Returns the value of attribute error

Returns:

  • (Object)

    the current value of error



21
22
23
# File 'lib/ucode/fetch/font_fetcher/result.rb', line 21

def error
  @error
end

#labelObject

Returns the value of attribute label

Returns:

  • (Object)

    the current value of label



21
22
23
# File 'lib/ucode/fetch/font_fetcher/result.rb', line 21

def label
  @label
end

#licenseObject

Returns the value of attribute license

Returns:

  • (Object)

    the current value of license



21
22
23
# File 'lib/ucode/fetch/font_fetcher/result.rb', line 21

def license
  @license
end

#noteObject

Returns the value of attribute note

Returns:

  • (Object)

    the current value of note



21
22
23
# File 'lib/ucode/fetch/font_fetcher/result.rb', line 21

def note
  @note
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



21
22
23
# File 'lib/ucode/fetch/font_fetcher/result.rb', line 21

def path
  @path
end

#provenanceObject

Returns the value of attribute provenance

Returns:

  • (Object)

    the current value of provenance



21
22
23
# File 'lib/ucode/fetch/font_fetcher/result.rb', line 21

def provenance
  @provenance
end

#size_bytesObject

Returns the value of attribute size_bytes

Returns:

  • (Object)

    the current value of size_bytes



21
22
23
# File 'lib/ucode/fetch/font_fetcher/result.rb', line 21

def size_bytes
  @size_bytes
end

#statusObject

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



21
22
23
# File 'lib/ucode/fetch/font_fetcher/result.rb', line 21

def status
  @status
end

Instance Method Details

#downloaded?Boolean

Returns:

  • (Boolean)


31
# File 'lib/ucode/fetch/font_fetcher/result.rb', line 31

def downloaded? = status == :downloaded

#failed?Boolean

Returns:

  • (Boolean)


33
# File 'lib/ucode/fetch/font_fetcher/result.rb', line 33

def failed? = status == :failed

#local?Boolean

Returns:

  • (Boolean)


34
# File 'lib/ucode/fetch/font_fetcher/result.rb', line 34

def local? = status == :local

#planned?Boolean

Returns:

  • (Boolean)


35
# File 'lib/ucode/fetch/font_fetcher/result.rb', line 35

def planned? = status == :planned

#skipped?Boolean

Returns:

  • (Boolean)


32
# File 'lib/ucode/fetch/font_fetcher/result.rb', line 32

def skipped? = status == :skipped