Class: OpenXml::Docx::Properties::ValueProperty

Inherits:
BaseProperty
  • Object
show all
Defined in:
lib/openxml/docx/properties/value_property.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseProperty

#default_name, #default_namespace, #default_tag, #name, name, namespace, #namespace, #tag, tag, tag_is_one_of

Constructor Details

#initialize(value) ⇒ ValueProperty

Returns a new instance of ValueProperty.

Raises:

  • (ArgumentError)


7
8
9
10
# File 'lib/openxml/docx/properties/value_property.rb', line 7

def initialize(value)
  @value = value
  raise ArgumentError, invalid_message unless valid?
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



5
6
7
# File 'lib/openxml/docx/properties/value_property.rb', line 5

def value
  @value
end

Instance Method Details

#invalid_messageObject



16
17
18
# File 'lib/openxml/docx/properties/value_property.rb', line 16

def invalid_message
  "Invalid value for #{name}; acceptable values are #{ok_values.join(", ")} (provided: #{value.inspect})"
end

#render?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/openxml/docx/properties/value_property.rb', line 20

def render?
  !value.nil?
end

#to_xml(xml) ⇒ Object



24
25
26
# File 'lib/openxml/docx/properties/value_property.rb', line 24

def to_xml(xml)
  xml["w"].public_send(tag, "w:val" => value)
end

#valid?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/openxml/docx/properties/value_property.rb', line 12

def valid?
  ok_values.member? value
end