Class: Jah::Pkg

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/jah/act_pkg/pkg.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Pkg

Returns a new instance of Pkg.



7
8
9
# File 'lib/jah/act_pkg/pkg.rb', line 7

def initialize(*args)
  @status, @name, @version, @desc = args
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*meth) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/jah/act_pkg/pkg.rb', line 44

def method_missing(*meth)
  unless (val = info[meth[0]]).nil?
    val
  else
    raise NoMethodError
  end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/jah/act_pkg/pkg.rb', line 5

def name
  @name
end

#sizeObject (readonly)

Returns the value of attribute size.



5
6
7
# File 'lib/jah/act_pkg/pkg.rb', line 5

def size
  @size
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/jah/act_pkg/pkg.rb', line 5

def status
  @status
end

#versionObject (readonly)

Returns the value of attribute version.



5
6
7
# File 'lib/jah/act_pkg/pkg.rb', line 5

def version
  @version
end

Instance Method Details

#<=>(other) ⇒ Object



34
35
36
37
# File 'lib/jah/act_pkg/pkg.rb', line 34

def <=>(other)
  raise "Not same pkg.." unless name == other.name
  version <=> other.version
end

#==(other) ⇒ Object



30
31
32
# File 'lib/jah/act_pkg/pkg.rb', line 30

def ==(other)
  (name == other.name) && (version == other.version)
end

#descObject



11
12
13
# File 'lib/jah/act_pkg/pkg.rb', line 11

def desc
  @desc ||= info[:desc]
end

#infoObject



15
16
17
# File 'lib/jah/act_pkg/pkg.rb', line 15

def info
  @info ||= ActPkg.info(self)
end

#installObject



23
24
25
# File 'lib/jah/act_pkg/pkg.rb', line 23

def install
  ActPkg.install(self)
end

#installed?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/jah/act_pkg/pkg.rb', line 19

def installed?
  @status == :installed
end

#uninstallObject



27
28
# File 'lib/jah/act_pkg/pkg.rb', line 27

def uninstall
end

#valid?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/jah/act_pkg/pkg.rb', line 39

def valid?
  !(@name.nil? or @version.nil?)
end