Class: Datasets::LIBSVMDatasetList::DescriptionListener
- Inherits:
-
Object
- Object
- Datasets::LIBSVMDatasetList::DescriptionListener
- Includes:
- REXML::StreamListener
- Defined in:
- lib/datasets/libsvm-dataset-list.rb
Instance Method Summary collapse
-
#initialize(abort_tag, description) ⇒ DescriptionListener
constructor
A new instance of DescriptionListener.
- #tag_end(name) ⇒ Object
- #tag_start(name, attributes) ⇒ Object
- #text(data) ⇒ Object
Constructor Details
#initialize(abort_tag, description) ⇒ DescriptionListener
Returns a new instance of DescriptionListener.
240 241 242 243 244 245 |
# File 'lib/datasets/libsvm-dataset-list.rb', line 240 def initialize(abort_tag, description) @abort_tag = abort_tag @description = description @in_content = false @p = nil end |
Instance Method Details
#tag_end(name) ⇒ Object
260 261 262 263 264 265 |
# File 'lib/datasets/libsvm-dataset-list.rb', line 260 def tag_end(name) case name when "p" @description << @p.join(" ") end end |
#tag_start(name, attributes) ⇒ Object
247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/datasets/libsvm-dataset-list.rb', line 247 def tag_start(name, attributes) case name when "p" @in_content = true @p = [] when "br" @description << @p.join(" ") @p = [] when "hr" throw(@abort_tag) end end |
#text(data) ⇒ Object
267 268 269 270 271 |
# File 'lib/datasets/libsvm-dataset-list.rb', line 267 def text(data) return unless @in_content content = data.gsub(/[ \t\n]+/, " ").strip @p << content unless content.empty? end |