class Parser::Sport

Public Class Methods

new(source) click to toggle source
# File lib/fly_parser/sources/sport.rb, line 4
def initialize(source)
  @source = Parser.connect(source)
  @categories = %w(Футбол Хоккей Баскетбол Авто/мото Теннис)
end

Public Instance Methods

current_page() click to toggle source
# File lib/fly_parser/sources/sport.rb, line 19
def current_page
  @source.link_with(:text => @category).click
end
parse_all() click to toggle source
# File lib/fly_parser/sources/sport.rb, line 23
def parse_all
  @categories.map { |category| parse_in(category) }
end
parse_in(category) click to toggle source
# File lib/fly_parser/sources/sport.rb, line 9
def parse_in(category)
  @category = category
  @current_page = current_page
  @current_page.search('.anons').map do |news_item|
    href = news_item.css('a').first.attributes['href'].value
    item_page = @current_page.link_with(:href => href).click
    { title: item_page.search('.titleH1').text(), content: item_page.search('.article-textBlock').text() }
  end  
end