Class: AtCoderFriends::Problem
- Inherits:
-
Object
- Object
- AtCoderFriends::Problem
- Defined in:
- lib/at_coder_friends/problem.rb
Overview
holds problem information
Defined Under Namespace
Classes: Constant, InputFormat, Options, SampleData, SourceCode
Constant Summary collapse
- SECTION_INTRO =
'INTRODUCTION'
- SECTION_STATEMENT =
'STATEMENT'
- SECTION_TASK =
'TASK'
- 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
-
#constants ⇒ Object
Returns the value of attribute constants.
-
#formats_src ⇒ Object
Returns the value of attribute formats_src.
-
#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
- #body_content ⇒ Object
- #formats ⇒ Object
-
#initialize(q, page = Mechanize::Page.new) {|_self| ... } ⇒ Problem
constructor
A new instance of Problem.
- #url ⇒ Object
Constructor Details
#initialize(q, page = Mechanize::Page.new) {|_self| ... } ⇒ Problem
Returns a new instance of Problem.
111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/at_coder_friends/problem.rb', line 111 def initialize(q, page = Mechanize::Page.new) @q = q @page = page @sections = {} @samples = [] @formats_src = [] @constants = [] @options = Options.new @sources = [] yield self if block_given? end |
Instance Attribute Details
#constants ⇒ Object
Returns the value of attribute constants.
109 110 111 |
# File 'lib/at_coder_friends/problem.rb', line 109 def constants @constants end |
#formats_src ⇒ Object
Returns the value of attribute formats_src.
109 110 111 |
# File 'lib/at_coder_friends/problem.rb', line 109 def formats_src @formats_src end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
108 109 110 |
# File 'lib/at_coder_friends/problem.rb', line 108 def @options end |
#page ⇒ Object
Returns the value of attribute page.
109 110 111 |
# File 'lib/at_coder_friends/problem.rb', line 109 def page @page end |
#q ⇒ Object (readonly)
Returns the value of attribute q.
108 109 110 |
# File 'lib/at_coder_friends/problem.rb', line 108 def q @q end |
#samples ⇒ Object (readonly)
Returns the value of attribute samples.
108 109 110 |
# File 'lib/at_coder_friends/problem.rb', line 108 def samples @samples end |
#sections ⇒ Object
Returns the value of attribute sections.
109 110 111 |
# File 'lib/at_coder_friends/problem.rb', line 109 def sections @sections end |
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
108 109 110 |
# File 'lib/at_coder_friends/problem.rb', line 108 def sources @sources end |
Instance Method Details
#add_smp(no, ext, txt) ⇒ Object
135 136 137 |
# File 'lib/at_coder_friends/problem.rb', line 135 def add_smp(no, ext, txt) @samples << SampleData.new(no, ext, txt) end |
#add_src(ext, txt) ⇒ Object
139 140 141 |
# File 'lib/at_coder_friends/problem.rb', line 139 def add_src(ext, txt) @sources << SourceCode.new(ext, txt) end |
#body_content ⇒ Object
127 128 129 |
# File 'lib/at_coder_friends/problem.rb', line 127 def body_content @body_content ||= page.search('body')[0]&.content end |
#formats ⇒ Object
131 132 133 |
# File 'lib/at_coder_friends/problem.rb', line 131 def formats @formats ||= formats_src.reject { |f| f.container == :unknown } end |
#url ⇒ Object
123 124 125 |
# File 'lib/at_coder_friends/problem.rb', line 123 def url @url ||= page.uri.to_s end |