Class: Inspec::Resources::Runlevels
- Defined in:
- lib/resources/service.rb
Instance Attribute Summary collapse
-
#owner ⇒ Object
Returns the value of attribute owner.
Class Method Summary collapse
Instance Method Summary collapse
-
#disabled? ⇒ boolean
Check if all runlevels are disabled.
-
#enabled? ⇒ boolean
Check if all runlevels are enabled.
- #filter(f) ⇒ Object
-
#initialize(owner, default = false) ⇒ Runlevels
constructor
A new instance of Runlevels.
- #to_s ⇒ Object
Methods inherited from Hash
#contains, #deep_merge, #smash
Constructor Details
#initialize(owner, default = false) ⇒ Runlevels
Returns a new instance of Runlevels.
32 33 34 35 |
# File 'lib/resources/service.rb', line 32 def initialize(owner, default = false) @owner = owner super(default) end |
Instance Attribute Details
#owner ⇒ Object
Returns the value of attribute owner.
8 9 10 |
# File 'lib/resources/service.rb', line 8 def owner @owner end |
Class Method Details
.from_hash(owner, hash = {}, filter = nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/resources/service.rb', line 10 def self.from_hash(owner, hash = {}, filter = nil) res = Runlevels.new(owner) filter = filter.first if filter.is_a?(Array) && filter.length <= 1 ks = case filter when nil hash.keys when Regexp hash.keys.find_all { |x| x.to_s =~ filter } when Array f = filter.map(&:to_s) hash.keys.find_all { |x| f.include?(x.to_s) } when Numeric hash.keys.include?(filter) ? [filter] : [] else hash.keys.find_all { |x| x == filter } end ks.each { |k| res[k] = hash[k] } res end |
Instance Method Details
#disabled? ⇒ boolean
Check if all runlevels are disabled
51 52 53 |
# File 'lib/resources/service.rb', line 51 def disabled? values.none? end |
#enabled? ⇒ boolean
Check if all runlevels are enabled
44 45 46 |
# File 'lib/resources/service.rb', line 44 def enabled? values.all? end |
#filter(f) ⇒ Object
37 38 39 |
# File 'lib/resources/service.rb', line 37 def filter(f) Runlevels.from_hash(owner, self, f) end |
#to_s ⇒ Object
55 56 57 |
# File 'lib/resources/service.rb', line 55 def to_s "#{owner} runlevels #{keys.join(', ')}" end |