Class: OpenSCAP::Xccdf::Item
- Inherits:
-
Object
- Object
- OpenSCAP::Xccdf::Item
- Defined in:
- lib/openscap/xccdf.rb,
lib/openscap/xccdf/item.rb
Class Method Summary collapse
Instance Method Summary collapse
- #description(prefered_lang = nil) ⇒ Object
- #destroy ⇒ Object
- #id ⇒ Object
-
#initialize(t) ⇒ Item
constructor
A new instance of Item.
- #rationale(prefered_lang = nil) ⇒ Object
- #references ⇒ Object
- #sub_items ⇒ Object
- #title(prefered_lang = nil) ⇒ Object
Constructor Details
Class Method Details
.build(t) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/openscap/xccdf/item.rb', line 21 def self.build(t) raise OpenSCAP::OpenSCAPError, "Cannot initialize #{self.class.name} with #{t}" \ unless t.is_a?(FFI::Pointer) # This is Abstract base class that enables you to build its child case OpenSCAP.xccdf_item_get_type t when :group OpenSCAP::Xccdf::Group.new t when :rule OpenSCAP::Xccdf::Rule.new t else raise OpenSCAP::OpenSCAPError, "Unknown #{self.class.name} type: #{OpenSCAP.xccdf_item_get_type t}" end end |
Instance Method Details
#description(prefered_lang = nil) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/openscap/xccdf/item.rb', line 53 def description(prefered_lang = nil) textlist = OpenSCAP::TextList.new(OpenSCAP.xccdf_item_get_description(@raw)) description = textlist.plaintext(prefered_lang) textlist.destroy description end |
#destroy ⇒ Object
82 83 84 85 |
# File 'lib/openscap/xccdf/item.rb', line 82 def destroy OpenSCAP.xccdf_item_free @raw @raw = nil end |
#id ⇒ Object
42 43 44 |
# File 'lib/openscap/xccdf/item.rb', line 42 def id OpenSCAP.xccdf_item_get_id @raw end |
#rationale(prefered_lang = nil) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/openscap/xccdf/item.rb', line 60 def rationale(prefered_lang = nil) textlist = OpenSCAP::TextList.new(OpenSCAP.xccdf_item_get_rationale(@raw)) rationale = textlist.plaintext(prefered_lang) textlist.destroy rationale end |
#references ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/openscap/xccdf/item.rb', line 67 def references refs = [] refs_it = OpenSCAP.xccdf_item_get_references(@raw) while OpenSCAP.oscap_reference_iterator_has_more refs_it ref = OpenSCAP::Xccdf::Reference.new(OpenSCAP.oscap_reference_iterator_next(refs_it)) refs << ref end OpenSCAP.oscap_reference_iterator_free refs_it refs end |
#sub_items ⇒ Object
78 79 80 |
# File 'lib/openscap/xccdf/item.rb', line 78 def sub_items @sub_items ||= sub_items_init end |