Class: AtCoderFriends::Generator::PythonRef

Inherits:
Base
  • Object
show all
Includes:
PythonRefConstants, ConstFragmentMixin, DeclFragmentMixin
Defined in:
lib/at_coder_friends/generator/python_ref.rb

Overview

generates Python source from problem description

Constant Summary collapse

ACF_HOME =
File.realpath(File.join(__dir__, '..', '..', '..'))
TMPL_DIR =
File.join(ACF_HOME, 'templates')
TEMPLATE =
File.join(TMPL_DIR, 'python_ref.py.erb')
FRAGMENTS =
File.realpath(File.join(TMPL_DIR, 'python_ref_fragments.yml'))
ATTRS =
Attributes.new(:py, TEMPLATE, FRAGMENTS)

Constants included from PythonRefConstants

AtCoderFriends::Generator::PythonRefConstants::VERSION

Instance Method Summary collapse

Instance Method Details

#attrsObject



22
23
24
# File 'lib/at_coder_friends/generator/python_ref.rb', line 22

def attrs
  ATTRS
end

#gen_constsObject



26
27
28
29
30
# File 'lib/at_coder_friends/generator/python_ref.rb', line 26

def gen_consts
  pbm.constants
    .select { |c| c.type == :mod }
    .map { |c| gen_const(c) }
end

#render(src) ⇒ Object

deprecated, use ERB syntax



33
34
35
36
# File 'lib/at_coder_friends/generator/python_ref.rb', line 33

def render(src)
  src = embed_lines(src, '### CONSTS ###', gen_consts)
  embed_lines(src, '### DCLS ###', gen_decls)
end