Class: AfrLoad::AfrLoad

Inherits:
Object
  • Object
show all
Defined in:
lib/afr_load.rb

Constant Summary collapse

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ AfrLoad

Returns a new instance of AfrLoad.

Yields:

  • (_self)

Yield Parameters:



18
19
20
21
22
# File 'lib/afr_load.rb', line 18

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

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



16
17
18
# File 'lib/afr_load.rb', line 16

def document
  @document
end

#programsObject (readonly)

Returns the value of attribute programs.



16
17
18
# File 'lib/afr_load.rb', line 16

def programs
  @programs
end

#urlObject

Returns the value of attribute url.



15
16
17
# File 'lib/afr_load.rb', line 15

def url
  @url
end

Class Method Details

.get_scheduleObject



24
25
26
27
28
# File 'lib/afr_load.rb', line 24

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

Instance Method Details

#get_programObject



39
40
41
# File 'lib/afr_load.rb', line 39

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

#get_scheduleObject



30
31
32
33
34
35
36
37
# File 'lib/afr_load.rb', line 30

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