Class: AtCoderFriends::Problem

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(q, page = Mechanize::Page.new) {|_self| ... } ⇒ Problem

Returns a new instance of Problem.

Yields:

  • (_self)

Yield Parameters:



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

#constantsObject

Returns the value of attribute constants.



109
110
111
# File 'lib/at_coder_friends/problem.rb', line 109

def constants
  @constants
end

#formats_srcObject

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

#optionsObject (readonly)

Returns the value of attribute options.



108
109
110
# File 'lib/at_coder_friends/problem.rb', line 108

def options
  @options
end

#pageObject

Returns the value of attribute page.



109
110
111
# File 'lib/at_coder_friends/problem.rb', line 109

def page
  @page
end

#qObject (readonly)

Returns the value of attribute q.



108
109
110
# File 'lib/at_coder_friends/problem.rb', line 108

def q
  @q
end

#samplesObject (readonly)

Returns the value of attribute samples.



108
109
110
# File 'lib/at_coder_friends/problem.rb', line 108

def samples
  @samples
end

#sectionsObject

Returns the value of attribute sections.



109
110
111
# File 'lib/at_coder_friends/problem.rb', line 109

def sections
  @sections
end

#sourcesObject (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_contentObject



127
128
129
# File 'lib/at_coder_friends/problem.rb', line 127

def body_content
  @body_content ||= page.search('body')[0]&.content
end

#formatsObject



131
132
133
# File 'lib/at_coder_friends/problem.rb', line 131

def formats
  @formats ||= formats_src.reject { |f| f.container == :unknown }
end

#urlObject



123
124
125
# File 'lib/at_coder_friends/problem.rb', line 123

def url
  @url ||= page.uri.to_s
end