Module: HtmlParser
- Included in:
- ParseDir
- Defined in:
- lib/html_parser.rb
Instance Method Summary collapse
- #class_exists?(tag, file) ⇒ Boolean
- #id_exists?(tag, file) ⇒ Boolean
- #parent_exists?(tag, file) ⇒ Boolean
- #read_html(file) ⇒ Object
- #remove_extras(file) ⇒ Object
Instance Method Details
#class_exists?(tag, file) ⇒ Boolean
22 23 24 25 26 27 28 29 |
# File 'lib/html_parser.rb', line 22 def class_exists? tag, file tag = tag.gsub('.', 'class') if tag.match(/^./) remove_extras(file).each do |line| if line.match(tag) return true end end end |
#id_exists?(tag, file) ⇒ Boolean
13 14 15 16 17 18 19 20 |
# File 'lib/html_parser.rb', line 13 def id_exists? tag, file tag = tag.gsub('#', 'id') remove_extras(file).each do |line| if line.match(tag) return true end end end |
#parent_exists?(tag, file) ⇒ Boolean
31 32 33 34 35 36 37 38 |
# File 'lib/html_parser.rb', line 31 def parent_exists? tag, file tag = tag.gsub('div.', 'class') if tag.match(/div/) remove_extras(file).each do |line| if line.match(tag) return true end end end |
#read_html(file) ⇒ Object
4 5 6 |
# File 'lib/html_parser.rb', line 4 def read_html file File.readlines(file) end |
#remove_extras(file) ⇒ Object
8 9 10 11 |
# File 'lib/html_parser.rb', line 8 def remove_extras file #the whitespace first read_html(file).map {|line| line.delete(" <%>:=''\"\"")} end |