Class: Muffins::Mapping

Inherits:
Object
  • Object
show all
Includes:
Virtus
Defined in:
lib/muffins/mapping.rb

Instance Method Summary collapse

Instance Method Details

#absolute_pathObject



24
25
26
# File 'lib/muffins/mapping.rb', line 24

def absolute_path
  within ? [ within, relative_path ].compact.join(" > ") : relative_path
end

#parse(doc) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/muffins/mapping.rb', line 12

def parse(doc)
  document = Muffins::Document.new(:body => doc.to_s)

  if collection?
    document.map(absolute_path) { |node| node.text }
  else
    node = document.first(absolute_path)
    node.text if node
  end
end

#relative_pathObject



29
30
31
# File 'lib/muffins/mapping.rb', line 29

def relative_path
  to || name
end