Class: XForms::Control
Instance Attribute Summary collapse
-
#binding ⇒ Object
Returns the value of attribute binding.
-
#constraint ⇒ Object
Returns the value of attribute constraint.
-
#constraint_message ⇒ Object
Returns the value of attribute constraint_message.
-
#form ⇒ Object
Returns the value of attribute form.
-
#readonly ⇒ Object
Returns the value of attribute readonly.
-
#relevant ⇒ Object
Returns the value of attribute relevant.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes included from Label
Instance Method Summary collapse
-
#initialize(form) ⇒ Control
constructor
A new instance of Control.
- #relevant? ⇒ Boolean
- #valid? ⇒ Boolean
- #value ⇒ Object
- #value=(value) ⇒ Object
Constructor Details
#initialize(form) ⇒ Control
Returns a new instance of Control.
49 50 51 52 |
# File 'lib/xforms/control.rb', line 49 def initialize(form) @form = form @readonly = false end |
Instance Attribute Details
#binding ⇒ Object
Returns the value of attribute binding.
41 42 43 |
# File 'lib/xforms/control.rb', line 41 def binding @binding end |
#constraint ⇒ Object
Returns the value of attribute constraint.
43 44 45 |
# File 'lib/xforms/control.rb', line 43 def constraint @constraint end |
#constraint_message ⇒ Object
Returns the value of attribute constraint_message.
44 45 46 |
# File 'lib/xforms/control.rb', line 44 def @constraint_message end |
#form ⇒ Object
Returns the value of attribute form.
40 41 42 |
# File 'lib/xforms/control.rb', line 40 def form @form end |
#readonly ⇒ Object
Returns the value of attribute readonly.
42 43 44 |
# File 'lib/xforms/control.rb', line 42 def readonly @readonly end |
#relevant ⇒ Object
Returns the value of attribute relevant.
45 46 47 |
# File 'lib/xforms/control.rb', line 45 def relevant @relevant end |
#type ⇒ Object
Returns the value of attribute type.
46 47 48 |
# File 'lib/xforms/control.rb', line 46 def type @type end |
Instance Method Details
#relevant? ⇒ Boolean
79 80 81 82 |
# File 'lib/xforms/control.rb', line 79 def relevant? return true unless @relevant @relevant.dyn_value end |
#valid? ⇒ Boolean
73 74 75 76 77 |
# File 'lib/xforms/control.rb', line 73 def valid? return true unless constraint node = form.model_instance.xpath(binding).first node.xpath(constraint) == true end |
#value ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/xforms/control.rb', line 59 def value data = form.model_instance.xpath(binding).first.inner_text return data unless type case type when 'int' then Integer(data) rescue 0 else data end end |
#value=(value) ⇒ Object
54 55 56 57 |
# File 'lib/xforms/control.rb', line 54 def value=(value) value = Integer(value).to_s if type == 'int' form.model_instance.xpath(binding).first.children = value end |