Class: Pvectl::Selectors::Volume
- Defined in:
- lib/pvectl/selectors/volume.rb,
sig/pvectl/selectors/volume.rbs
Overview
Selector for filtering virtual disk volumes.
Extends Base with volume-specific field extraction. Supports: format, storage, node, content, resource_type, name.
Constant Summary collapse
- SUPPORTED_FIELDS =
%w[format storage node content resource_type name].freeze
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#apply(volumes) ⇒ Array<Models::Volume>
Applies selector to volume collection.
-
#extract_value(vol, field) ⇒ String?
Extracts field value from Volume model.
Methods inherited from Base
#compare_value, #empty?, #initialize, #match_condition?, #matches?, parse, parse_all, #wildcard_match?
Constructor Details
This class inherits a constructor from Pvectl::Selectors::Base
Instance Method Details
#apply(volumes) ⇒ Array<Models::Volume>
Applies selector to volume collection.
25 26 27 28 29 |
# File 'lib/pvectl/selectors/volume.rb', line 25 def apply(volumes) return volumes if empty? volumes.select { |vol| matches?(vol) } end |
#extract_value(vol, field) ⇒ String?
Extracts field value from Volume model.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/pvectl/selectors/volume.rb', line 39 def extract_value(vol, field) case field when "format" vol.format when "storage" vol.storage when "node" vol.node when "content" vol.content when "resource_type" vol.resource_type when "name" vol.name else raise ArgumentError, "Unknown field: #{field}. Supported: #{SUPPORTED_FIELDS.join(', ')}" end end |