class RuboCop::Schema::AsciiDoc::Base

Attributes

root[R]

@return [Asciidoctor::Document]

Public Class Methods

new(ascii_block) click to toggle source

@param [Asciidoctor::AbstractBlock] ascii_block

# File lib/rubocop/schema/ascii_doc/base.rb, line 11
def initialize(ascii_block)
  @root = ascii_block
  scan
end

Protected Instance Methods

presence(str) click to toggle source
# File lib/rubocop/schema/ascii_doc/base.rb, line 46
def presence(str)
  str unless str.strip == ''
end
scan() click to toggle source
# File lib/rubocop/schema/ascii_doc/base.rb, line 21
def scan
  raise NotImplementedError
end
stringify_section(section) click to toggle source
# File lib/rubocop/schema/ascii_doc/base.rb, line 41
def stringify_section(section)
  @stringifier ||= Stringifier.new
  @stringifier.stringify section
end
table_to_hash(table) click to toggle source

@param [Asciidoctor::Table] table @return [Array<Hash>] A hash for each row, with table headings as keys

# File lib/rubocop/schema/ascii_doc/base.rb, line 32
def table_to_hash(table)
  headings = table.rows.head.first.map(&:text)
  table.rows.body.map do |row|
    headings.each_with_index.map do |heading, i|
      [heading, strip_html(row[i].text)]
    end.to_h
  end
end