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
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/openscap/xccdf/item.rb', line 12 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
46 47 48 49 50 51 |
# File 'lib/openscap/xccdf/item.rb', line 46 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
75 76 77 78 |
# File 'lib/openscap/xccdf/item.rb', line 75 def destroy OpenSCAP.xccdf_item_free @raw @raw = nil end |
#id ⇒ Object
35 36 37 |
# File 'lib/openscap/xccdf/item.rb', line 35 def id OpenSCAP.xccdf_item_get_id @raw end |
#rationale(prefered_lang = nil) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/openscap/xccdf/item.rb', line 53 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
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/openscap/xccdf/item.rb', line 60 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
71 72 73 |
# File 'lib/openscap/xccdf/item.rb', line 71 def sub_items @sub_items ||= sub_items_init end |