Class: Rocx::Properties::ValueProperty

Inherits:
BaseProperty show all
Defined in:
lib/rocx/properties/value_property.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseProperty

#default_name, #default_tag, name, #name, tag, #tag

Constructor Details

#initialize(value) ⇒ ValueProperty

Returns a new instance of ValueProperty.

Raises:

  • (ArgumentError)


6
7
8
9
# File 'lib/rocx/properties/value_property.rb', line 6

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



4
5
6
# File 'lib/rocx/properties/value_property.rb', line 4

def value
  @value
end

Instance Method Details

#invalid_messageObject



15
16
17
# File 'lib/rocx/properties/value_property.rb', line 15

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

#render?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/rocx/properties/value_property.rb', line 19

def render?
  !value.nil?
end

#to_xml(xml) ⇒ Object



23
24
25
# File 'lib/rocx/properties/value_property.rb', line 23

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

#valid?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/rocx/properties/value_property.rb', line 11

def valid?
  ok_values.member? value
end