Module: Hpricot::Traverse
- Defined in:
- lib/parser.rb
Instance Method Summary collapse
Instance Method Details
#between(a, b) ⇒ Object
243 244 245 |
# File 'lib/parser.rb', line 243 def between(a,b) root.search(a..b) end |
#extract_text ⇒ Object
247 248 249 250 251 252 253 |
# File 'lib/parser.rb', line 247 def extract_text t='' self.traverse_all_element do |e| t+=e.content.to_s if e.is_a?(Hpricot::Text) end t end |
#in_search?(expr) ⇒ Boolean
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/parser.rb', line 219 def in_search?(expr) if expr !~ /[^a-z0-9]/ return self.name.downcase()==expr.downcase() end se_in=self.parent if expr[0..1]=='/' se_in=self.root end se_in.search(expr).each do |el| return true if el==self end # puts self.name+" "+expr return false end |
#root ⇒ Object
235 236 237 238 239 240 241 |
# File 'lib/parser.rb', line 235 def root return @root unless @root.nil? se_in=self se_in=se_in.parent until se_in.parent.nil? @root=se_in se_in end |