36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/facepricot.rb', line 36
def make_facepricot_chain(key, doc)
if matches = /(.*)_list/.match(key)
listKey = matches[1]
end
result = nil
if !result
if listKey
result = doc.search("/#{listKey}")
end
end
if !result
result = doc.at("/#{key}")
end
if !result
if listKey
result = doc.search("//#{listKey}")
end
end
if !result
result = doc.at("//#{key}")
end
if result
if result.is_a?(Array)
return result.map{|r| FacepricotChain.new(r)}
else
return FacepricotChain.new(result)
end
else
return nil
end
end
|