class Evesync::IPC::Data::Package

Attributes

command[R]
name[R]
timestamp[R]
version[R]

Public Class Methods

new(params) click to toggle source
# File lib/evesync/ipc/data/package.rb, line 20
def initialize(params)
  @name = params[:name].freeze
  @version = params[:version].freeze
  @command = parse_command(params[:command]).freeze
  @timestamp = params[:timestamp] || NTP.timestamp
end

Public Instance Methods

==(pkg) click to toggle source
# File lib/evesync/ipc/data/package.rb, line 27
def ==(pkg)
  (pkg.name == @name) &&
    (pkg.version == @version) &&
    (pkg.command == @command)
end
to_s() click to toggle source
# File lib/evesync/ipc/data/package.rb, line 33
def to_s
  "Package(#{@command.upcase}: #{name}-#{@version})"
end

Private Instance Methods

parse_command(command) click to toggle source
# File lib/evesync/ipc/data/package.rb, line 39
def parse_command(command)
  cmd = case command
        when /^inst\w+$/
          Command::INSTALL
        when /^(remove\w*|delete\w*)$/
          Command::REMOVE
        when /^(update\w*|upgrade\w*)$/
          Command::UPDATE
        when /^downgrade\w*$/
          Command::DOWNGRADE
        else
          Command::UNKNOWN
        end

  cmd.to_s
end