Class: MonoclePrint::Graphics

Inherits:
Struct
  • Object
show all
Extended by:
GraphicsRegistry
Includes:
MonoclePrint
Defined in:
lib/monocle-print/graphics.rb,
lib/monocle-print/graphics.rb

Constant Summary

Constants included from GraphicsRegistry

MonoclePrint::GraphicsRegistry::ENV_KEY, MonoclePrint::GraphicsRegistry::FALLBACK_STYLE

Constants included from MonoclePrint

COLOR_ESCAPE, FOUR_BYTES, MULTIBYTE_CHARACTER, ONE_BYTE, THREE_BYTES, TWO_BYTES, VERSION

Instance Attribute Summary collapse

Attributes included from GraphicsRegistry

#default_style

Instance Method Summary collapse

Methods included from GraphicsRegistry

default, define, named_styles, style, style?, styles

Methods included from MonoclePrint

Line, Output, Rectangle, Style, Text, buffer, included, library_path, stderr, stdout, version

Instance Attribute Details

#blankObject

Returns the value of attribute blank

Returns:

  • (Object)

    the current value of blank



7
8
9
# File 'lib/monocle-print/graphics.rb', line 7

def blank
  @blank
end

#enObject

Returns the value of attribute en

Returns:

  • (Object)

    the current value of en



7
8
9
# File 'lib/monocle-print/graphics.rb', line 7

def en
  @en
end

#ensObject

Returns the value of attribute ens

Returns:

  • (Object)

    the current value of ens



7
8
9
# File 'lib/monocle-print/graphics.rb', line 7

def ens
  @ens
end

#enswObject

Returns the value of attribute ensw

Returns:

  • (Object)

    the current value of ensw



7
8
9
# File 'lib/monocle-print/graphics.rb', line 7

def ensw
  @ensw
end

#enwObject

Returns the value of attribute enw

Returns:

  • (Object)

    the current value of enw



7
8
9
# File 'lib/monocle-print/graphics.rb', line 7

def enw
  @enw
end

#esObject

Returns the value of attribute es

Returns:

  • (Object)

    the current value of es



7
8
9
# File 'lib/monocle-print/graphics.rb', line 7

def es
  @es
end

#eswObject

Returns the value of attribute esw

Returns:

  • (Object)

    the current value of esw



7
8
9
# File 'lib/monocle-print/graphics.rb', line 7

def esw
  @esw
end

#ewObject Also known as: h

Returns the value of attribute ew

Returns:

  • (Object)

    the current value of ew



7
8
9
# File 'lib/monocle-print/graphics.rb', line 7

def ew
  @ew
end

#nsObject Also known as: v

Returns the value of attribute ns

Returns:

  • (Object)

    the current value of ns



7
8
9
# File 'lib/monocle-print/graphics.rb', line 7

def ns
  @ns
end

#nswObject

Returns the value of attribute nsw

Returns:

  • (Object)

    the current value of nsw



7
8
9
# File 'lib/monocle-print/graphics.rb', line 7

def nsw
  @nsw
end

#nwObject

Returns the value of attribute nw

Returns:

  • (Object)

    the current value of nw



7
8
9
# File 'lib/monocle-print/graphics.rb', line 7

def nw
  @nw
end

#swObject

Returns the value of attribute sw

Returns:

  • (Object)

    the current value of sw



7
8
9
# File 'lib/monocle-print/graphics.rb', line 7

def sw
  @sw
end

#tree_forkObject

Returns the value of attribute tree_fork

Returns:

  • (Object)

    the current value of tree_fork



7
8
9
# File 'lib/monocle-print/graphics.rb', line 7

def tree_fork
  @tree_fork
end

#tree_tailObject

Returns the value of attribute tree_tail

Returns:

  • (Object)

    the current value of tree_tail



7
8
9
# File 'lib/monocle-print/graphics.rb', line 7

def tree_tail
  @tree_tail
end

Instance Method Details

#box_bottom(width) ⇒ Object



51
52
53
# File 'lib/monocle-print/graphics.rb', line 51

def box_bottom( width )
  format( "<ne><ew:#{ width }><nw>" )
end

#box_top(width) ⇒ Object



47
48
49
# File 'lib/monocle-print/graphics.rb', line 47

def box_top( width )
  format( "<se><ew:#{ width }><sw>" )
end

#format(description) ⇒ Object



34
35
36
37
38
39
40
41
# 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) ⇒ Object



43
44
45
# File 'lib/monocle-print/graphics.rb', line 43

def horizontal_line( width )
  ew.tile( width )
end

#line_with_joints(joint, *widths) ⇒ Object



67
68
69
# 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) ⇒ Object



63
64
65
# 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) ⇒ Object



59
60
61
# 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) ⇒ Object



55
56
57
# File 'lib/monocle-print/graphics.rb', line 55

def table_top( *column_widths )
  nw + line_with_joints( esw, column_widths ) + ne
end