Class Ariel::Node::Structure
In: lib/ariel/node/structure.rb
Parent: Node

Implements a Node object used to represent the structure of the document tree. Each node stores start and end rules to extract the desired content from its parent node. Could be viewed as a rule-storing object.

Methods

Attributes

node_type  [RW] 
ruleset  [RW] 

Public Class methods

Public Instance methods

Applies the extraction rules stored in the current Node::Structure and all its descendant children.

Used to extend an already created Node. e.g.

 node.extend_structure do |r|
   r.item :new_field1
   r.item :new_field2
 end

Given a Node to apply it’s rules to, this function will create a new node and add it as a child of the given node. It returns an array of the items extracted by the rule

Use when defining any object that occurs once. list is a synonym, but it’s recommended you use it when defining a container for list_items. The children of a list_item are just items. e.g. <tt>structure = Ariel::Node::Structure.new do |r|

  r.list :comments do |c|  # r.item :comments would be equivalent, but less readable
    c.list_item :comment do |c|
      c.item :author  # Now these are just normal items, as they are extracted once from their parent
      c.item :date
      c.item :body
    end
  end

end

list(name, &block)

Alias for item

See the docs for item for a discussion of when to use item and when to use list_item.

[Validate]