Class: AtCoderFriends::Problem

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Problem.

Yields:

  • (_self)

Yield Parameters:



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 = Options.new
  @sources = []
  yield self if block_given?
end

Instance Attribute Details

#constraintsObject

Returns the value of attribute constraints.



31
32
33
# File 'lib/at_coder_friends/problem.rb', line 31

def constraints
  @constraints
end

#formatsObject

Returns the value of attribute formats.



31
32
33
# File 'lib/at_coder_friends/problem.rb', line 31

def formats
  @formats
end

#optionsObject (readonly)

Returns the value of attribute options.



30
31
32
# File 'lib/at_coder_friends/problem.rb', line 30

def options
  @options
end

#pageObject

Returns the value of attribute page.



31
32
33
# File 'lib/at_coder_friends/problem.rb', line 31

def page
  @page
end

#qObject (readonly)

Returns the value of attribute q.



30
31
32
# File 'lib/at_coder_friends/problem.rb', line 30

def q
  @q
end

#samplesObject (readonly)

Returns the value of attribute samples.



30
31
32
# File 'lib/at_coder_friends/problem.rb', line 30

def samples
  @samples
end

#sectionsObject

Returns the value of attribute sections.



31
32
33
# File 'lib/at_coder_friends/problem.rb', line 31

def sections
  @sections
end

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



49
50
51
# File 'lib/at_coder_friends/problem.rb', line 49

def page_body
  @page_body ||= page.body.force_encoding('utf-8')
end

#urlObject



45
46
47
# File 'lib/at_coder_friends/problem.rb', line 45

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