class MonoclePrint::Graphics

Public Instance Methods

box_bottom( width ) click to toggle source
# File lib/monocle-print/graphics.rb, line 51
def box_bottom( width )
  format( "<ne><ew:#{ width }><nw>" )
end
box_top( width ) click to toggle source
# File lib/monocle-print/graphics.rb, line 47
def box_top( width )
  format( "<se><ew:#{ width }><sw>" )
end
format( description ) click to toggle source
# File lib/monocle-print/graphics.rb, line 34
def format( description )
  out = Line( description )
  out.gsub!( /<([nsewlrtbudhv]+)(?::(\d+))?>/i ) do
    box_bit = resolve_name( $1 )
    $2 ? box_bit.tile( $2.to_i ) : box_bit
  end
  return( out )
end
horizontal_line( width ) click to toggle source
# File lib/monocle-print/graphics.rb, line 43
def horizontal_line( width )
  ew.tile( width )
end
line_with_joints( joint, *widths ) click to toggle source
# File lib/monocle-print/graphics.rb, line 67
def line_with_joints( joint, *widths )
  widths.map { | w | horizontal_line( w ) }.join( joint )
end
table_bottom( *column_widths ) click to toggle source
# File lib/monocle-print/graphics.rb, line 63
def table_bottom( *column_widths )
  sw + line_with_joints( enw, column_widths ) + se
end
table_divide( *column_widths ) click to toggle source
# File lib/monocle-print/graphics.rb, line 59
def table_divide( *column_widths )
  ens + line_with_joints( ensw, column_widths ) + nsw
end
table_top( *column_widths ) click to toggle source
# File lib/monocle-print/graphics.rb, line 55
def table_top( *column_widths )
  nw + line_with_joints( esw, column_widths ) + ne
end

Private Instance Methods

resolve_name( name ) click to toggle source
# File lib/monocle-print/graphics.rb, line 76
def resolve_name( name )
  name.downcase!
  name.tr!( 'lrtbud', 'wensns' )
  name.gsub!( 'h', 'ew' )
  name.gsub!( 'v', 'ns' )
  chars = name.chars.to_a.sort!
  chars.uniq!
  self[ chars.join('') ]
end