Class: DCloud::HardwareProfile::Property
- Inherits:
-
Object
- Object
- DCloud::HardwareProfile::Property
- Defined in:
- lib/dcloud/hardware_profile.rb
Direct Known Subclasses
Defined Under Namespace
Instance Attribute Summary collapse
-
#enum ⇒ Object
readonly
Returns the value of attribute enum.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#range ⇒ Object
readonly
Returns the value of attribute range.
-
#unit ⇒ Object
readonly
Returns the value of attribute unit.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(xml, name) ⇒ Property
constructor
A new instance of Property.
- #present? ⇒ Boolean
-
#to_s ⇒ Object
FIXME: how to range/enum/kind bits fit into this?.
Constructor Details
#initialize(xml, name) ⇒ Property
Returns a new instance of Property.
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/dcloud/hardware_profile.rb', line 53 def initialize(xml, name) @name = name p = REXML::XPath.first(xml, "property[@name = '#{name}']") if p @value = p.attributes['value'] @unit = p.attributes['unit'] @kind = p.attributes['kind'] @range = Range.new(p.get_elements('range')[0]) if @kind=='range' @enum = Enum.new(p.get_elements('enum')[0]) if @kind=='enum' end end |
Instance Attribute Details
#enum ⇒ Object (readonly)
Returns the value of attribute enum.
51 52 53 |
# File 'lib/dcloud/hardware_profile.rb', line 51 def enum @enum end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
51 52 53 |
# File 'lib/dcloud/hardware_profile.rb', line 51 def kind @kind end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
51 52 53 |
# File 'lib/dcloud/hardware_profile.rb', line 51 def name @name end |
#range ⇒ Object (readonly)
Returns the value of attribute range.
51 52 53 |
# File 'lib/dcloud/hardware_profile.rb', line 51 def range @range end |
#unit ⇒ Object (readonly)
Returns the value of attribute unit.
51 52 53 |
# File 'lib/dcloud/hardware_profile.rb', line 51 def unit @unit end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
51 52 53 |
# File 'lib/dcloud/hardware_profile.rb', line 51 def value @value end |
Instance Method Details
#present? ⇒ Boolean
65 66 67 |
# File 'lib/dcloud/hardware_profile.rb', line 65 def present? ! @value.nil? end |
#to_s ⇒ Object
FIXME: how to range/enum/kind bits fit into this?
70 71 72 73 74 75 |
# File 'lib/dcloud/hardware_profile.rb', line 70 def to_s v = @value || "---" u = @unit || "" u = "" if ["label", "count"].include?(u) "#{v} #{u}" end |