class AtCoderFriends::Parser::IntroductionWrapper

holds introduction of problrem page

Attributes

div[R]

Public Class Methods

new(div) click to toggle source
# File lib/at_coder_friends/parser/introduction_wrapper.rb, line 9
def initialize(div)
  @div = div
end

Public Instance Methods

extract_intro(node) click to toggle source
# File lib/at_coder_friends/parser/introduction_wrapper.rb, line 21
def extract_intro(node)
  found = false
  node.children.each do |cld|
    found = true if %w[h2 h3].any? { |h| cld.name == h }
    if found
      cld.remove
    else
      found = extract_intro(cld)
    end
  end
  found
end
html() click to toggle source
# File lib/at_coder_friends/parser/introduction_wrapper.rb, line 34
def html
  @html ||= intro.to_html.gsub("\r\n", "\n")
end
intro() click to toggle source
# File lib/at_coder_friends/parser/introduction_wrapper.rb, line 13
def intro
  @intro ||= begin
    div2 = div.dup
    extract_intro(div2)
    div2
  end
end