Class: XForms::Form

Inherits:
Object show all
Defined in:
lib/xforms/form.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeForm

Returns a new instance of Form.



9
10
11
12
13
# File 'lib/xforms/form.rb', line 9

def initialize
  @controls = []
  @namespaces = {}
  @calculates = []
end

Instance Attribute Details

#calculatesObject

Returns the value of attribute calculates.



7
8
9
# File 'lib/xforms/form.rb', line 7

def calculates
  @calculates
end

#controlsObject

Returns the value of attribute controls.



5
6
7
# File 'lib/xforms/form.rb', line 5

def controls
  @controls
end

#itextObject

Returns the value of attribute itext.



4
5
6
# File 'lib/xforms/form.rb', line 4

def itext
  @itext
end

#model_instanceObject

Returns the value of attribute model_instance.



3
4
5
# File 'lib/xforms/form.rb', line 3

def model_instance
  @model_instance
end

#namespacesObject

Returns the value of attribute namespaces.



6
7
8
# File 'lib/xforms/form.rb', line 6

def namespaces
  @namespaces
end

Class Method Details

.parse(input) ⇒ Object



21
22
23
# File 'lib/xforms/form.rb', line 21

def self.parse(input)
  FormParser.new(input).parse
end

.parse_file(path) ⇒ Object



15
16
17
18
19
# File 'lib/xforms/form.rb', line 15

def self.parse_file(path)
  File.open(path, 'r') do |f|
    parse f
  end
end

Instance Method Details

#recalculateObject



25
26
27
28
29
30
# File 'lib/xforms/form.rb', line 25

def recalculate
  calculates.each do |calc|
    value = calc[:value].dyn_value
    model_instance.xpath(calc[:binding]).first.children = value.to_s
  end
end