You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: annotation.rb
    path of file: ./repos/consuldemocracy/app/models/legislation
    
    the code of the file until where you have to start completion: class Legislation::Annotation 
    
  def store_context
    begin
      html = draft_version.body_html
      doc = Nokogiri::HTML(html)

      selector_start = "/html/body/#{range_start}"
      el_start = doc.at_xpath(selector_start)

      selector_end = "/html/body/#{range_end}"
      el_end = doc.at_xpath(selector_end)

      remainder_el_start = el_start.text[0..range_start_offset - 1] unless range_start_offset.zero?
      remainder_el_end = el_end.text[range_end_offset..-1]

      self.context = "#{remainder_el_start}<span class=annotator-hl>#{quote}</span>#{remainder_el_end}"
    rescue
      "<span class=annotator-hl>#{quote}</span>"
    end
  end

  def create_first_comment
    comments.create(body: text, user: author)
  end

  def title
    text[0..50]
  end

  def weight
    comments_count + comments.sum(:cached_votes_total)
  end

  def comments_closed?
    !draft_version.process.allegations_phase.open?
  end
end