Method: X2CH::BbsMenu.parse

Defined in:
lib/x2ch.rb

.parse(html) ⇒ Object



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/x2ch.rb', line 167

def self.parse(html)
  bbs = Bbs.new
  category = nil
  html.each_line{|l|
    cname = l.match(/<BR><BR><B>(.+?)<\/B><BR>/).to_a[1]
    if cname
      if IGNORE_CATEGORIES.include?(cname)
        category = nil
      else
        category = Category.new(cname)
        bbs.push(category)
      end

      next
    end

    next unless category

    b = l.match(/<A HREF=(http:\/\/.*(?:\.2ch\.sc|\.bbspink\.com|\.machi\.to)[^\s]*).*>(.+)<\/A>/).to_a
    if b[0]
      next if IGNORE_BOARDS.include?(b[2])

      board = Board.new(b[1], b[2])
      category.push(board)
    end
  }
  bbs
end