Sha256: 907149c07eb14cd8d68a008971afa81ae563d8f58a0bdd4a4a073cff83895806

Contents?: true

Size: 877 Bytes

Versions: 3

Compression:

Stored size: 877 Bytes

Contents

# encoding: utf-8

require "oga"
require "httpclient"

require "bundler"
Bundler.require(:default, :development)
require "afr_load/version"
require "afr_load/parser.rb"

module AfrLoad
  class AfrLoad
    AFR_LOAD_URL = "http://www.tv-tokyo.co.jp/telecine/oa_afr_load/"

    attr_accessor :url 
    attr_reader :programs, :document

    def initialize()
      @url = AFR_LOAD_URL
      @programs = Array.new()
      yield(self) if block_given?
    end

    def self.get_schedule()
      afr = self.new()
      afr.get_schedule()
      afr.get_program()
    end

    def get_schedule()
      if @url.start_with?("http")
        body = HTTPClient.get(@url).body.force_encoding("utf-8")
      else
        body = File.open(@url).read
      end
      @document = Oga.parse_html(body)
    end

    def get_program
      @programs = Parser.parse(@document).flatten
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
afr_load-0.1.9 lib/afr_load.rb
afr_load-0.1.8 lib/afr_load.rb
afr_load-0.1.7 lib/afr_load.rb