Module: ActiveXML
- Included in:
- Collection, Object
- Defined in:
- lib/active_xml.rb,
lib/active_xml/object.rb,
lib/active_xml/version.rb,
lib/active_xml/collection.rb,
lib/active_xml/collection/query.rb,
lib/active_xml/collection/route.rb
Defined Under Namespace
Classes: Collection, Object
Constant Summary
collapse
- VERSION =
"0.0.3"
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
Returns the value of attribute path.
14
15
16
|
# File 'lib/active_xml.rb', line 14
def path
@path
end
|
Instance Method Details
#delete_node(key) ⇒ Object
34
35
36
|
# File 'lib/active_xml.rb', line 34
def delete_node(key)
xml.search(key).remove
end
|
#initialize(path) ⇒ Object
16
17
18
19
20
|
# File 'lib/active_xml.rb', line 16
def initialize(path)
@path = Pathname.new(path)
create_file(@path, '<null_tag/>') unless @path.exist?
set_root!
end
|
30
31
32
|
# File 'lib/active_xml.rb', line 30
def save
@path.open('w') {|f| f.write(@xml.to_xml) }
end
|
#set_root! ⇒ Object
26
27
28
|
# File 'lib/active_xml.rb', line 26
def set_root!
xml.root.name = root
end
|
22
23
24
|
# File 'lib/active_xml.rb', line 22
def xml
@xml ||= Nokogiri::XML(@path.read)
end
|