class Terminal::Table::UnicodeBorder
Constants
- ALLOWED_SEPARATOR_BORDER_STYLES
- HORIZONTALS
- INTERSECTIONS
- VERTICALS
Public Class Methods
new()
click to toggle source
Calls superclass method
Terminal::Table::Border::new
# File lib/terminal-table/style.rb, line 89 def initialize super @data = { nil => nil, nw: "┌", nx: "─", n: "┬", ne: "┐", yw: "│", y: "│", ye: "│", aw: "╞", ax: "═", ai: "╪", ae: "╡", ad: '╤', au: "╧", # double bw: "┝", bx: "━", bi: "┿", be: "┥", bd: '┯', bu: "┷", # heavy/bold/thick w: "├", x: "─", i: "┼", e: "┤", dn: "┬", up: "┴", # normal div sw: "└", sx: "─", s: "┴", se: "┘", # alternative dots/dashes x_dot4: '┈', x_dot3: '┄', x_dash: '╌', bx_dot4: '┉', bx_dot3: '┅', bx_dash: '╍', } end
Public Instance Methods
horizontal(type)
click to toggle source
Get horizontal border elements @return [Array] a 6 element list of: [i-left, horizontal-bar, i-up/down, i-right, i-down, i-up]
# File lib/terminal-table/style.rb, line 112 def horizontal(type) raise ArgumentError, "Border type is #{type.inspect}, must be one of #{ALLOWED_SEPARATOR_BORDER_STYLES.inspect}" unless ALLOWED_SEPARATOR_BORDER_STYLES.include?(type) lookup = case type when :top [:nw, :nx, :n, :ne, :n, nil] when :bot [:sw, :sx, :s, :se, nil, :s] when :double # typically used for the separator below the heading row or above a footer row) [:aw, :ax, :ai, :ae, :ad, :au] when :thick, :thick_dash, :thick_dot3, :thick_dot4, :heavy, :heavy_dash, :heavy_dot3, :heavy_dot4, :bold, :bold_dash, :bold_dot3, :bold_dot4 # alternate thick/bold border xref = type.to_s.sub(/^(thick|heavy|bold)/,'bx').to_sym [:bw, xref, :bi, :be, :bd, :bu] when :dash, :dot3, :dot4 # alternate thin dividers xref = "x_#{type}".to_sym [:w, xref, :i, :e, :dn, :up] else # :div (center, non-emphasized) [:w, :x, :i, :e, :dn, :up] end rval = lookup.map { |key| @data.fetch(key) } rval[0] = '' unless @left rval[3] = '' unless @right rval end
vertical()
click to toggle source
Get vertical border elements @return [Array] 3-element list of [left, center, right]
# File lib/terminal-table/style.rb, line 106 def vertical [maybeleft(:yw), @data[:y], mayberight(:ye)] end