lib/infoboxer/tree/table.rb in infoboxer-0.3.3 vs lib/infoboxer/tree/table.rb in infoboxer-0.4.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'terminal-table' module Infoboxer module Tree # Represents table. Tables are complicated! @@ -22,16 +24,16 @@ # For now, returns first table row, if it consists only of # {TableHeading}s. # # FIXME: it can easily be several table heading rows def heading_row - rows.first if rows.first && rows.first.children.all? { |c| c.is_a?(TableHeading) } + rows.first if rows.first&.children&.all? { |c| c.is_a?(TableHeading) } end # For now, returns all table rows except {#heading_row} def body_rows - if rows.first && rows.first.children.all? { |c| c.is_a?(TableHeading) } - rows[1..-1] + if rows.first&.children&.all? { |c| c.is_a?(TableHeading) } + rows[1..] else rows end end