Module: HMachine::Pattern::ValueClass
- Extended by:
- HMachine
- Defined in:
- lib/hmachine/pattern/valueclass.rb
Constant Summary
collapse
- WIKI_URL =
'http://microformats.org/wiki/value-class-pattern'
Constants included
from HMachine
HMachine::PRODID, VERSION
Class Method Summary
collapse
Methods included from HMachine
extract, extract_from, find, find_in, found_in?, get, get_document, get_url, map, normalize, parse, parse_first, search, valid?, validate
Class Method Details
.get_text(node) ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/hmachine/pattern/valueclass.rb', line 39
def self.get_text(node)
if ((node.node_name.eql?('img') || node.node_name.eql?('area')) && node['alt'])
node['alt'].strip
elsif (node.node_name.eql?('object') && node['data'])
node['data'].strip
else
node.content.strip
end
end
|
.get_values(node) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/hmachine/pattern/valueclass.rb', line 25
def self.get_values(node)
find_in(node).collect do |val|
if ((val.node_name.eql?('img') || val.node_name.eql?('area')) && val['alt'])
val['alt'].strip
elsif (val.node_name.eql?('object') && val['data'])
val['data'].strip
elsif (Abbr.valid?(val) || val.matches?('.value-title'))
val['title'].strip
else
val.content.strip
end
end
end
|