Class: OpenXml::Properties::ValueProperty
- Inherits:
-
BaseProperty
- Object
- BaseProperty
- OpenXml::Properties::ValueProperty
- Defined in:
- lib/openxml/properties/value_property.rb
Direct Known Subclasses
BooleanProperty, IntegerProperty, OnOffProperty, StringProperty
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(value) ⇒ ValueProperty
constructor
A new instance of ValueProperty.
- #invalid_message ⇒ Object
- #render? ⇒ Boolean
- #to_xml(xml) ⇒ Object
- #valid? ⇒ Boolean
Methods inherited from BaseProperty
#default_name, #default_tag, name, #name, namespace, #namespace, tag, #tag, tag_is_one_of, #validate_tag
Constructor Details
#initialize(value) ⇒ ValueProperty
Returns a new instance of ValueProperty.
6 7 8 9 |
# File 'lib/openxml/properties/value_property.rb', line 6 def initialize(value) @value = value raise ArgumentError, unless valid? end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'lib/openxml/properties/value_property.rb', line 4 def value @value end |
Instance Method Details
#invalid_message ⇒ Object
15 16 17 |
# File 'lib/openxml/properties/value_property.rb', line 15 def "#{value.inspect} is an invalid value for #{name}; acceptable: #{ok_values.join(", ")}" end |
#render? ⇒ Boolean
19 20 21 |
# File 'lib/openxml/properties/value_property.rb', line 19 def render? !value.nil? end |
#to_xml(xml) ⇒ Object
23 24 25 26 27 |
# File 'lib/openxml/properties/value_property.rb', line 23 def to_xml(xml) apply_namespace(xml).public_send(tag, :"#{value_attribute}" => value) do yield xml if block_given? end end |
#valid? ⇒ Boolean
11 12 13 |
# File 'lib/openxml/properties/value_property.rb', line 11 def valid? ok_values.member? value end |