class Shellject::Tasks::Load

Loads, decrypts, and outputs a shelljection

Attributes

name[R]
save_directory[R]

Public Class Methods

new(save_directory, name) click to toggle source
# File lib/shellject/tasks/load.rb, line 10
def initialize(save_directory, name)
  @save_directory = save_directory
  @name = name
end

Public Instance Methods

call() click to toggle source
# File lib/shellject/tasks/load.rb, line 15
def call
  ensure_readable
  file = File.open path
  STDOUT.print crypto.decrypt(file)
ensure
  file&.close
end

Private Instance Methods

ensure_readable() click to toggle source
# File lib/shellject/tasks/load.rb, line 25
def ensure_readable
  raise ShelljectError, "Could not read file #{path}" unless readable?
end
path() click to toggle source
# File lib/shellject/tasks/load.rb, line 33
def path
  @path ||= save_directory.path_for name
end
readable?() click to toggle source
# File lib/shellject/tasks/load.rb, line 29
def readable?
  path.readable?
end