Sha256: 36b53b15e7683d30a052d54cddf3e2d573ad1bb13e2e5678630f1335974b3452

Contents?: true

Size: 966 Bytes

Versions: 1

Compression:

Stored size: 966 Bytes

Contents

# encoding: utf-8

require "oga"
require "httpclient"
require "byebug"

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

1 entries across 1 versions & 1 rubygems

Version Path
afr_load-0.1.5 lib/afr_load.rb