Class: AfrLoad::AfrLoad
- Inherits:
-
Object
- Object
- AfrLoad::AfrLoad
- 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
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#programs ⇒ Object
readonly
Returns the value of attribute programs.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #get_program ⇒ Object
- #get_schedule ⇒ Object
-
#initialize {|_self| ... } ⇒ AfrLoad
constructor
A new instance of AfrLoad.
Constructor Details
#initialize {|_self| ... } ⇒ AfrLoad
Returns a new instance of AfrLoad.
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
#document ⇒ Object (readonly)
Returns the value of attribute document.
16 17 18 |
# File 'lib/afr_load.rb', line 16 def document @document end |
#programs ⇒ Object (readonly)
Returns the value of attribute programs.
16 17 18 |
# File 'lib/afr_load.rb', line 16 def programs @programs end |
#url ⇒ Object
Returns the value of attribute url.
15 16 17 |
# File 'lib/afr_load.rb', line 15 def url @url end |
Class Method Details
.get_schedule ⇒ Object
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_program ⇒ Object
39 40 41 |
# File 'lib/afr_load.rb', line 39 def get_program @programs = Parser.parse(@document).flatten end |
#get_schedule ⇒ Object
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 |