Class: LinuxAdmin::Distros::Distro
- Inherits:
-
Object
- Object
- LinuxAdmin::Distros::Distro
- Defined in:
- lib/linux_admin/distro.rb
Instance Attribute Summary collapse
-
#etc_issue_keywords ⇒ Object
Returns the value of attribute etc_issue_keywords.
-
#info_class ⇒ Object
Returns the value of attribute info_class.
-
#release_file ⇒ Object
Returns the value of attribute release_file.
Instance Method Summary collapse
- #command(name) ⇒ Object
- #detected? ⇒ Boolean
- #detected_by_etc_issue? ⇒ Boolean
- #detected_by_etc_release? ⇒ Boolean
- #info(pkg) ⇒ Object
-
#initialize(id, release_file = nil, etc_issue_keywords = [], info_class = nil) ⇒ Distro
constructor
A new instance of Distro.
Constructor Details
#initialize(id, release_file = nil, etc_issue_keywords = [], info_class = nil) ⇒ Distro
Returns a new instance of Distro.
39 40 41 42 43 44 45 |
# File 'lib/linux_admin/distro.rb', line 39 def initialize(id, release_file = nil, etc_issue_keywords = [], info_class = nil) @id = id @path = %w(/sbin /bin /usr/bin /usr/sbin) @release_file = release_file @etc_issue_keywords = etc_issue_keywords @info_class = info_class end |
Instance Attribute Details
#etc_issue_keywords ⇒ Object
Returns the value of attribute etc_issue_keywords.
37 38 39 |
# File 'lib/linux_admin/distro.rb', line 37 def etc_issue_keywords @etc_issue_keywords end |
#info_class ⇒ Object
Returns the value of attribute info_class.
37 38 39 |
# File 'lib/linux_admin/distro.rb', line 37 def info_class @info_class end |
#release_file ⇒ Object
Returns the value of attribute release_file.
37 38 39 |
# File 'lib/linux_admin/distro.rb', line 37 def release_file @release_file end |
Instance Method Details
#command(name) ⇒ Object
59 60 61 |
# File 'lib/linux_admin/distro.rb', line 59 def command(name) @path.collect { |dir| "#{dir}/#{name}" }.detect { |cmd| File.exist?(cmd) } end |
#detected? ⇒ Boolean
47 48 49 |
# File 'lib/linux_admin/distro.rb', line 47 def detected? detected_by_etc_issue? || detected_by_etc_release? end |
#detected_by_etc_issue? ⇒ Boolean
51 52 53 |
# File 'lib/linux_admin/distro.rb', line 51 def detected_by_etc_issue? etc_issue_keywords && etc_issue_keywords.any? { |k| EtcIssue.instance.include?(k) } end |
#detected_by_etc_release? ⇒ Boolean
55 56 57 |
# File 'lib/linux_admin/distro.rb', line 55 def detected_by_etc_release? release_file && File.exist?(release_file) end |
#info(pkg) ⇒ Object
63 64 65 |
# File 'lib/linux_admin/distro.rb', line 63 def info(pkg) info_class ? info_class.info(pkg) : nil end |