Class: AtCoderFriends::Problem
- Inherits:
-
Object
- Object
- AtCoderFriends::Problem
- Defined in:
- lib/at_coder_friends/problem.rb
Overview
holds problem information
Defined Under Namespace
Classes: Constraint, InputFormat, Options, SampleData, SourceCode
Constant Summary collapse
- SECTION_IN_FMT =
'INPUT_FORMAT'- SECTION_OUT_FMT =
'OUTPUT_FORMAT'- SECTION_IO_FMT =
'INOUT_FORMAT'- SECTION_CONSTRAINTS =
'CONSTRAINTS'- SECTION_IN_SMP =
'INPUT_SAMPLE_%<no>s'- SECTION_IN_SMP_PAT =
/^INPUT_SAMPLE_(?<no>\d+)$/.freeze
- SECTION_OUT_SMP =
'OUTPUT_SAMPLE_%<no>s'- SECTION_OUT_SMP_PAT =
/^OUTPUT_SAMPLE_(?<no>\d+)$/.freeze
- SECTION_IO_SMP =
'INOUT_SAMPLE'
Instance Attribute Summary collapse
-
#constraints ⇒ Object
Returns the value of attribute constraints.
-
#formats ⇒ Object
Returns the value of attribute formats.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#page ⇒ Object
Returns the value of attribute page.
-
#q ⇒ Object
readonly
Returns the value of attribute q.
-
#samples ⇒ Object
readonly
Returns the value of attribute samples.
-
#sections ⇒ Object
Returns the value of attribute sections.
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
Instance Method Summary collapse
- #add_smp(no, ext, txt) ⇒ Object
- #add_src(ext, txt) ⇒ Object
-
#initialize(q, page = Mechanize::Page.new) {|_self| ... } ⇒ Problem
constructor
A new instance of Problem.
- #page_body ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(q, page = Mechanize::Page.new) {|_self| ... } ⇒ Problem
Returns a new instance of Problem.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/at_coder_friends/problem.rb', line 33 def initialize(q, page = Mechanize::Page.new) @q = q @page = page @sections = {} @samples = [] @formats = [] @constraints = [] = Options.new @sources = [] yield self if block_given? end |
Instance Attribute Details
#constraints ⇒ Object
Returns the value of attribute constraints.
31 32 33 |
# File 'lib/at_coder_friends/problem.rb', line 31 def constraints @constraints end |
#formats ⇒ Object
Returns the value of attribute formats.
31 32 33 |
# File 'lib/at_coder_friends/problem.rb', line 31 def formats @formats end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
30 31 32 |
# File 'lib/at_coder_friends/problem.rb', line 30 def end |
#page ⇒ Object
Returns the value of attribute page.
31 32 33 |
# File 'lib/at_coder_friends/problem.rb', line 31 def page @page end |
#q ⇒ Object (readonly)
Returns the value of attribute q.
30 31 32 |
# File 'lib/at_coder_friends/problem.rb', line 30 def q @q end |
#samples ⇒ Object (readonly)
Returns the value of attribute samples.
30 31 32 |
# File 'lib/at_coder_friends/problem.rb', line 30 def samples @samples end |
#sections ⇒ Object
Returns the value of attribute sections.
31 32 33 |
# File 'lib/at_coder_friends/problem.rb', line 31 def sections @sections end |
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
30 31 32 |
# File 'lib/at_coder_friends/problem.rb', line 30 def sources @sources end |
Instance Method Details
#add_smp(no, ext, txt) ⇒ Object
53 54 55 |
# File 'lib/at_coder_friends/problem.rb', line 53 def add_smp(no, ext, txt) @samples << SampleData.new(no, ext, txt) end |
#add_src(ext, txt) ⇒ Object
57 58 59 |
# File 'lib/at_coder_friends/problem.rb', line 57 def add_src(ext, txt) @sources << SourceCode.new(ext, txt) end |
#page_body ⇒ Object
49 50 51 |
# File 'lib/at_coder_friends/problem.rb', line 49 def page_body @page_body ||= page.body.force_encoding('utf-8') end |
#url ⇒ Object
45 46 47 |
# File 'lib/at_coder_friends/problem.rb', line 45 def url @url ||= page.uri.to_s end |