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
21 22 23 24 25 26 27 28 |
# File 'lib/html_parser.rb', line 21 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
12 13 14 15 16 17 18 19 |
# File 'lib/html_parser.rb', line 12 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
30 31 32 33 34 35 36 37 |
# File 'lib/html_parser.rb', line 30 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 |
# File 'lib/html_parser.rb', line 8 def remove_extras file read_html(file).map {|line| line.delete(" <%>:=''\"\"")} end |