Class: LVM::Wrapper::LVSSEG

Inherits:
Object
  • Object
show all
Includes:
Reporting
Defined in:
lib/lvm/wrapper/lvsseg.rb

Overview

segment output is very different in that its multi line, easier to treat as own command

Constant Summary collapse

BASE_COMMAND =
"lvs #{Reporting::BASE_ARGUMENTS}".freeze
ATTRIBUTES_FILE =
"lvsseg.yaml".freeze

Constants included from Reporting::Constants

Reporting::Constants::BASE_ARGUMENTS, Reporting::Constants::EMPTY, Reporting::Constants::SEPERATOR

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Reporting

build_command, process_line

Constructor Details

#initialize(options) ⇒ LVSSEG

Returns a new instance of LVSSEG.



13
14
15
16
# File 'lib/lvm/wrapper/lvsseg.rb', line 13

def initialize(options)
  @attributes = Attributes.load(options[:version], ATTRIBUTES_FILE)
  @command = "#{options[:command]} #{Reporting.build_command(attributes, BASE_COMMAND, options[:additional_arguments])}"
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



10
11
12
# File 'lib/lvm/wrapper/lvsseg.rb', line 10

def attributes
  @attributes
end

#commandObject (readonly)

Returns the value of attribute command.



11
12
13
# File 'lib/lvm/wrapper/lvsseg.rb', line 11

def command
  @command
end

Instance Method Details

#listObject



21
22
23
24
25
26
27
28
29
# File 'lib/lvm/wrapper/lvsseg.rb', line 21

def list
  output = External.cmd(@command)
  data = parse(output)
  if block_given?
    data.each { |obj| yield obj }
  else
    data
  end
end