Module: Goldendocx::Element::ClassMethods
- Defined in:
- lib/goldendocx/element.rb
Instance Method Summary collapse
- #adapt?(xml_node) ⇒ Boolean
- #concerning_ancestors ⇒ Object
- #namespace(*args) ⇒ Object
- #parse(xml_string) ⇒ Object
- #read_from(xml_node) ⇒ Object
- #tag(*args) ⇒ Object
- #tag_name ⇒ Object
Instance Method Details
#adapt?(xml_node) ⇒ Boolean
32 33 34 |
# File 'lib/goldendocx/element.rb', line 32 def adapt?(xml_node) tag_name == xml_node.tag_name end |
#concerning_ancestors ⇒ Object
45 46 47 |
# File 'lib/goldendocx/element.rb', line 45 def concerning_ancestors ancestors.filter { |ancestor| ancestor.include?(Goldendocx::Element) } end |
#namespace(*args) ⇒ Object
18 19 20 21 |
# File 'lib/goldendocx/element.rb', line 18 def namespace(*args) @namespace = args.first if args.any? @namespace end |
#parse(xml_string) ⇒ Object
27 28 29 30 |
# File 'lib/goldendocx/element.rb', line 27 def parse(xml_string) root_node = Goldendocx.xml_serializer.parse(xml_string).root read_from(root_node) end |
#read_from(xml_node) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/goldendocx/element.rb', line 36 def read_from(xml_node) return unless adapt?(xml_node) instance = new instance.read_attributes(xml_node) instance.read_children(xml_node) instance end |
#tag(*args) ⇒ Object
13 14 15 16 |
# File 'lib/goldendocx/element.rb', line 13 def tag(*args) @tag = args.first if args.any? @tag end |
#tag_name ⇒ Object
23 24 25 |
# File 'lib/goldendocx/element.rb', line 23 def tag_name @tag_name ||= [namespace, tag].compact.join(':') end |