Class: CForces::Problem
- Inherits:
-
Object
- Object
- CForces::Problem
- Defined in:
- lib/codeforcesapi/CForces.rb
Instance Attribute Summary collapse
-
#contest_id ⇒ Object
readonly
Returns the value of attribute contest_id.
-
#preTestInputs ⇒ Object
readonly
Returns the value of attribute preTestInputs.
-
#preTestOutputs ⇒ Object
readonly
Returns the value of attribute preTestOutputs.
-
#problem_index ⇒ Object
readonly
Returns the value of attribute problem_index.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(cID, pindex) ⇒ Problem
constructor
A new instance of Problem.
- #loadURL(cid, pindex) ⇒ Object
Constructor Details
#initialize(cID, pindex) ⇒ Problem
Returns a new instance of Problem.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/codeforcesapi/CForces.rb', line 16 def initialize(cID, pindex) @contest_id = cID.to_s @problem_index = pindex @url = loadURL(cID, pindex) doc = Nokogiri::HTML(open(@url)) @preTestInputs = Array.new @preTestOutputs = Array.new doc.css('div.sample-test div.input').each do |e| @preTestInputs << e.css('br').map{|item| item.previous.text} end doc.css('div.sample-test div.output').each do |e| @preTestOutputs << e.css('br').map{|item| item.previous.text} end @title = doc.css('div.title')[0].text.delete('.').split.join '_' end |
Instance Attribute Details
#contest_id ⇒ Object (readonly)
Returns the value of attribute contest_id.
10 11 12 |
# File 'lib/codeforcesapi/CForces.rb', line 10 def contest_id @contest_id end |
#preTestInputs ⇒ Object (readonly)
Returns the value of attribute preTestInputs.
10 11 12 |
# File 'lib/codeforcesapi/CForces.rb', line 10 def preTestInputs @preTestInputs end |
#preTestOutputs ⇒ Object (readonly)
Returns the value of attribute preTestOutputs.
10 11 12 |
# File 'lib/codeforcesapi/CForces.rb', line 10 def preTestOutputs @preTestOutputs end |
#problem_index ⇒ Object (readonly)
Returns the value of attribute problem_index.
10 11 12 |
# File 'lib/codeforcesapi/CForces.rb', line 10 def problem_index @problem_index end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
10 11 12 |
# File 'lib/codeforcesapi/CForces.rb', line 10 def title @title end |
Instance Method Details
#loadURL(cid, pindex) ⇒ Object
12 13 14 |
# File 'lib/codeforcesapi/CForces.rb', line 12 def loadURL(cid, pindex) ['http://codeforces.com/contest/', '/problem/'].join(cid.to_s) + pindex.to_s end |