Class: XForms::Control

Inherits:
Object show all
Includes:
Label
Defined in:
lib/xforms/control.rb

Direct Known Subclasses

Input, Select1

Instance Attribute Summary collapse

Attributes included from Label

#label

Instance Method Summary collapse

Constructor Details

#initialize(form) ⇒ Control

Returns a new instance of Control.



42
43
44
45
# File 'lib/xforms/control.rb', line 42

def initialize(form)
  @form = form
  @readonly = false
end

Instance Attribute Details

#bindingObject

Returns the value of attribute binding.



35
36
37
# File 'lib/xforms/control.rb', line 35

def binding
  @binding
end

#constraintObject

Returns the value of attribute constraint.



37
38
39
# File 'lib/xforms/control.rb', line 37

def constraint
  @constraint
end

#constraint_messageObject

Returns the value of attribute constraint_message.



38
39
40
# File 'lib/xforms/control.rb', line 38

def constraint_message
  @constraint_message
end

#formObject

Returns the value of attribute form.



34
35
36
# File 'lib/xforms/control.rb', line 34

def form
  @form
end

#readonlyObject

Returns the value of attribute readonly.



36
37
38
# File 'lib/xforms/control.rb', line 36

def readonly
  @readonly
end

#relevantObject

Returns the value of attribute relevant.



39
40
41
# File 'lib/xforms/control.rb', line 39

def relevant
  @relevant
end

Instance Method Details

#relevant?Boolean

Returns:

  • (Boolean)


65
66
67
68
# File 'lib/xforms/control.rb', line 65

def relevant?
  return true unless @relevant
  @relevant.dyn_value
end

#valid?Boolean

Returns:

  • (Boolean)


59
60
61
62
63
# File 'lib/xforms/control.rb', line 59

def valid?
  return true unless constraint
  node = form.model_instance.xpath(binding).first
  node.xpath(constraint) == true
end

#valueObject



51
52
53
# File 'lib/xforms/control.rb', line 51

def value
  form.model_instance.xpath(binding).first.inner_text
end

#value=(value) ⇒ Object



47
48
49
# File 'lib/xforms/control.rb', line 47

def value=(value)
  form.model_instance.xpath(binding).first.children = value
end