R
Ramza Brown
I am trying to figure out how scope works with method in methods (or
actually overriding).
For example, below with the:
def parser.startElement(n, data)
I want to pass top-level variables to it, but I am getting an error the
object is nil.
/html_extract.rb:72:in `startElement': undefined method
`meta_description=' for nil:NilClass (NoMet
odError)
from ./ymhtml.rb:1024:in `parse'
from ./html_extract.rb:95:in `html_parse'
from ./html_extract.rb:115:in `fetch_http_document'
from ./html_extract.rb:46:in `connect_http'
from html_extract_main.rb:12:in `html_extract_main'
from html_extract_main.rb:15
class HTMLMetadata
attr_writer :meta_description
attr_writer :meta_keywords
attr_writer :document_size
attr_writer :links
....
....
# Parse and extract
parser = YmHTML:arser.new
parser.eliminateWhiteSpace = true
@html_data = HTMLMetadata.new()
# Process only links and the meta tag (including keywords)
def parser.startElement(n, data)
case n
when 'meta'
# Extract the meta content including keywords
# and description
if data['name']
type_lower = data['name'].downcase
if type_lower == 'description'
puts data['content'].downcase
@html_data.meta_description = data['content'].downcase
end
--
Berlin Brown
(ramaza3 on freenode)
http://www.newspiritcompany.com
http://www.newspiritcompany.com/newforums
also checkout alpha version of botverse:
http://www.newspiritcompany.com:8086/universe_home
actually overriding).
For example, below with the:
def parser.startElement(n, data)
I want to pass top-level variables to it, but I am getting an error the
object is nil.
/html_extract.rb:72:in `startElement': undefined method
`meta_description=' for nil:NilClass (NoMet
odError)
from ./ymhtml.rb:1024:in `parse'
from ./html_extract.rb:95:in `html_parse'
from ./html_extract.rb:115:in `fetch_http_document'
from ./html_extract.rb:46:in `connect_http'
from html_extract_main.rb:12:in `html_extract_main'
from html_extract_main.rb:15
class HTMLMetadata
attr_writer :meta_description
attr_writer :meta_keywords
attr_writer :document_size
attr_writer :links
....
....
# Parse and extract
parser = YmHTML:arser.new
parser.eliminateWhiteSpace = true
@html_data = HTMLMetadata.new()
# Process only links and the meta tag (including keywords)
def parser.startElement(n, data)
case n
when 'meta'
# Extract the meta content including keywords
# and description
if data['name']
type_lower = data['name'].downcase
if type_lower == 'description'
puts data['content'].downcase
@html_data.meta_description = data['content'].downcase
end
--
Berlin Brown
(ramaza3 on freenode)
http://www.newspiritcompany.com
http://www.newspiritcompany.com/newforums
also checkout alpha version of botverse:
http://www.newspiritcompany.com:8086/universe_home