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.
243 244 245 246 247 248 |
# File 'lib/datasets/libsvm-dataset-list.rb', line 243 def initialize(abort_tag, description) @abort_tag = abort_tag @description = description @in_content = false @p = nil end |
Instance Method Details
#tag_end(name) ⇒ Object
263 264 265 266 267 268 |
# File 'lib/datasets/libsvm-dataset-list.rb', line 263 def tag_end(name) case name when "p" @description << @p.join(" ") end end |
#tag_start(name, attributes) ⇒ Object
250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/datasets/libsvm-dataset-list.rb', line 250 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
270 271 272 273 274 |
# File 'lib/datasets/libsvm-dataset-list.rb', line 270 def text(data) return unless @in_content content = data.gsub(/[ \t\n]+/, " ").strip @p << content unless content.empty? end |