Class: Base4R::SomethingUnits

Inherits:
Attribute show all
Defined in:
lib/attribute.rb

Direct Known Subclasses

FloatUnitAttribute, NumberUnits

Instance Attribute Summary collapse

Attributes inherited from Attribute

#name, #namespace, #options, #private_attribute

Instance Method Summary collapse

Methods inherited from Attribute

#private_attribute?, #to_xml, to_xml, #type_name, type_name, #type_name=

Methods included from AdditionalXmlAttributeMethods

#additional_xml_attribute_map, included, #xml_attribute_value, #xml_attributes

Methods included from ChildAttributeMethods

#add_child, #add_child_attribute, #child, #children, #children_map, #children_names, included

Constructor Details

#initialize(*args) ⇒ SomethingUnits

Returns a new instance of SomethingUnits.



280
281
282
283
284
# File 'lib/attribute.rb', line 280

def initialize(*args)
  super(*args)
  @units = options.delete(:units)
  @value_without_units = @value
end

Instance Attribute Details

#unitsObject

Returns the value of attribute units.



277
278
279
# File 'lib/attribute.rb', line 277

def units
  @units
end

#value_without_unitsObject

Returns the value of attribute value_without_units.



278
279
280
# File 'lib/attribute.rb', line 278

def value_without_units
  @value_without_units
end

Instance Method Details

#valueObject



286
# File 'lib/attribute.rb', line 286

def value; "#{@value_without_units} #{@units}".strip;  end

#value=(v) ⇒ Object



287
# File 'lib/attribute.rb', line 287

def value=(v); @value_without_units, @units = v.split; end