Class: PojOrg::Problem
- Inherits:
-
Object
- Object
- PojOrg::Problem
- Defined in:
- lib/poj_org/problem.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#memory_limit_in_kb ⇒ Object
readonly
Returns the value of attribute memory_limit_in_kb.
-
#time_limit_in_ms ⇒ Object
readonly
Returns the value of attribute time_limit_in_ms.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(id) ⇒ Problem
constructor
A new instance of Problem.
- #url ⇒ Object
Constructor Details
#initialize(id) ⇒ Problem
Returns a new instance of Problem.
9 10 11 12 13 14 15 16 |
# File 'lib/poj_org/problem.rb', line 9 def initialize(id) @id = id html = Nokogiri::HTML(open(url)) raise PojOrg::Errors::ProblemNotFound if html.xpath('/html/head/title').text == 'Error' @title = html.xpath('/html/body/table[2]/tr/td/div[2]').text @time_limit_in_ms = html.xpath('/html/body/table[2]/tr/td/div[3]/table/tr[1]/td[1]').text[/\d+/].to_i @memory_limit_in_kb = html.xpath('/html/body/table[2]/tr/td/div[3]/table/tr[1]/td[3]').text[/\d+/].to_i end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/poj_org/problem.rb', line 7 def id @id end |
#memory_limit_in_kb ⇒ Object (readonly)
Returns the value of attribute memory_limit_in_kb.
7 8 9 |
# File 'lib/poj_org/problem.rb', line 7 def memory_limit_in_kb @memory_limit_in_kb end |
#time_limit_in_ms ⇒ Object (readonly)
Returns the value of attribute time_limit_in_ms.
7 8 9 |
# File 'lib/poj_org/problem.rb', line 7 def time_limit_in_ms @time_limit_in_ms end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/poj_org/problem.rb', line 7 def title @title end |
Instance Method Details
#url ⇒ Object
18 19 20 |
# File 'lib/poj_org/problem.rb', line 18 def url "http://poj.org/problem?id=#{id}" end |