class Datasets::LIBSVMDatasetList::IndexListener

Public Class Methods

new(abort_tag, &block) click to toggle source
# File lib/datasets/libsvm-dataset-list.rb, line 103
def initialize(abort_tag, &block)
  @abort_tag = abort_tag
  @block = block
  @row = nil
  @in_td = false
end

Public Instance Methods

tag_end(name) click to toggle source
# File lib/datasets/libsvm-dataset-list.rb, line 122
def tag_end(name)
  case name
  when "table"
    throw(@abort_tag)
  when "tr"
    name_column = @row[0]
    return unless name_column
    record = Record.new
    record.name = name_column[:text]
    record.files = []
    @block.call(name_column[:href], record)
  when "td"
    @in_td = false
  end
end
tag_start(name, attributes) click to toggle source
# File lib/datasets/libsvm-dataset-list.rb, line 110
def tag_start(name, attributes)
  case name
  when "tr"
    @row = []
  when "td"
    @in_td = true
    @row << {:text => ""}
  when "a"
    @row.last[:href] = attributes["href"] if @in_td
  end
end
text(data) click to toggle source
# File lib/datasets/libsvm-dataset-list.rb, line 138
def text(data)
  @row.last[:text] << data if @in_td
end