Module: RSS::ListenerMixin
- Included in:
- REXMLListener, XMLParserListener, XMLScanListener
- Defined in:
- lib/rss/0.9.rb,
lib/rss/1.0.rb,
lib/rss/parser.rb
Instance Attribute Summary collapse
-
#do_validate ⇒ Object
Returns the value of attribute do_validate.
-
#ignore_unknown_element ⇒ Object
Returns the value of attribute ignore_unknown_element.
-
#rss ⇒ Object
readonly
Returns the value of attribute rss.
Instance Method Summary collapse
- #initialize ⇒ Object
- #instruction(name, content) ⇒ Object
- #tag_end(name) ⇒ Object
- #tag_start(name, attributes) ⇒ Object
- #text(data) ⇒ Object
-
#xmldecl(version, encoding, standalone) ⇒ Object
set instance vars for version, encoding, standalone.
Instance Attribute Details
#do_validate ⇒ Object
Returns the value of attribute do_validate.
268 269 270 |
# File 'lib/rss/parser.rb', line 268 def do_validate @do_validate end |
#ignore_unknown_element ⇒ Object
Returns the value of attribute ignore_unknown_element.
267 268 269 |
# File 'lib/rss/parser.rb', line 267 def ignore_unknown_element @ignore_unknown_element end |
#rss ⇒ Object (readonly)
Returns the value of attribute rss.
265 266 267 |
# File 'lib/rss/parser.rb', line 265 def rss @rss end |
Instance Method Details
#initialize ⇒ Object
270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/rss/parser.rb', line 270 def initialize @rss = nil @ignore_unknown_element = true @do_validate = true @ns_stack = [{}] @tag_stack = [[]] @text_stack = [''] @proc_stack = [] @last_element = nil @version = @encoding = @standalone = nil @xml_stylesheets = [] end |
#instruction(name, content) ⇒ Object
288 289 290 291 292 293 294 295 |
# File 'lib/rss/parser.rb', line 288 def instruction(name, content) if name == "xml-stylesheet" params = parse_pi_content(content) if params.has_key?("href") @xml_stylesheets << XMLStyleSheet.new(*params) end end end |
#tag_end(name) ⇒ Object
321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/rss/parser.rb', line 321 def tag_end(name) if DEBUG p "end tag #{name}" p @tag_stack end text = @text_stack.pop = @tag_stack.pop pr = @proc_stack.pop pr.call(text, ) unless pr.nil? @ns_stack.pop end |
#tag_start(name, attributes) ⇒ Object
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
# File 'lib/rss/parser.rb', line 297 def tag_start(name, attributes) @text_stack.push('') ns = @ns_stack.last.dup attrs = {} attributes.each do |n, v| if /\Axmlns(?:\z|:)/ =~ n ns[$POSTMATCH] = v else attrs[n] = v end end @ns_stack.push(ns) prefix, local = split_name(name) @tag_stack.last.push([_ns(ns, prefix), local]) @tag_stack.push([]) if respond_to?("start_#{local}", true) __send__("start_#{local}", local, prefix, attrs, ns.dup) else start_else_element(local, prefix, attrs, ns.dup) end end |
#text(data) ⇒ Object
333 334 335 |
# File 'lib/rss/parser.rb', line 333 def text(data) @text_stack.last << data end |
#xmldecl(version, encoding, standalone) ⇒ Object
set instance vars for version, encoding, standalone
284 285 286 |
# File 'lib/rss/parser.rb', line 284 def xmldecl(version, encoding, standalone) @version, @encoding, @standalone = version, encoding, standalone end |