Class: GProv::Provision::EntryBase::XMLAttr
- Inherits:
-
Object
- Object
- GProv::Provision::EntryBase::XMLAttr
- Defined in:
- lib/gprov/provision/entrybase/xmlattr.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
The name attribute is not used by this class, but is used by calling classes to determine the method/attribute name they’ll use to associate with this object.
Instance Method Summary collapse
-
#initialize(name, options = {}) ⇒ XMLAttr
constructor
A new instance of XMLAttr.
-
#parse(xml) ⇒ Object
Given an XML document, use the supplied xpath value to extract the desired value for this attribute from the document.
- #type(val = nil) ⇒ Object
- #xpath(val = nil) ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ XMLAttr
Returns a new instance of XMLAttr.
40 41 42 43 44 |
# File 'lib/gprov/provision/entrybase/xmlattr.rb', line 40 def initialize(name, ={}) @name = name @type = :string methodhash() end |
Instance Attribute Details
#name ⇒ Object (readonly)
The name attribute is not used by this class, but is used by calling classes to determine the method/attribute name they’ll use to associate with this object.
38 39 40 |
# File 'lib/gprov/provision/entrybase/xmlattr.rb', line 38 def name @name end |
Instance Method Details
#parse(xml) ⇒ Object
Given an XML document, use the supplied xpath value to extract the desired value for this attribute from the document.
64 65 66 67 |
# File 'lib/gprov/provision/entrybase/xmlattr.rb', line 64 def parse(xml) @value = xml.at_xpath(@xpath).to_s format end |
#type(val = nil) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/gprov/provision/entrybase/xmlattr.rb', line 51 def type(val=nil) if [:numeric, :string, :bool].include? val @type = val else raise ArgumentError, "#{@type} is not recognized as a valid format type" end @type end |
#xpath(val = nil) ⇒ Object
46 47 48 49 |
# File 'lib/gprov/provision/entrybase/xmlattr.rb', line 46 def xpath(val=nil) @xpath = val if val @xpath end |