Class: MonoclePrint::Graphics
- Inherits:
-
Struct
- Object
- Struct
- MonoclePrint::Graphics
- Includes:
- MonoclePrint
- Defined in:
- lib/monocle-print/graphics.rb,
lib/monocle-print/graphics.rb
Constant Summary collapse
- NAMED_STYLES =
Hash.new { |h, k| h[ DEFAULT_STYLE ].dup }
- DEFAULT_STYLE =
default_style
Constants included from MonoclePrint
COLOR_ESCAPE, FOUR_BYTES, MULTIBYTE_CHARACTER, ONE_BYTE, THREE_BYTES, TWO_BYTES, VERSION
Instance Attribute Summary collapse
-
#blank ⇒ Object
Returns the value of attribute blank.
-
#en ⇒ Object
Returns the value of attribute en.
-
#ens ⇒ Object
Returns the value of attribute ens.
-
#ensw ⇒ Object
Returns the value of attribute ensw.
-
#enw ⇒ Object
Returns the value of attribute enw.
-
#es ⇒ Object
Returns the value of attribute es.
-
#esw ⇒ Object
Returns the value of attribute esw.
-
#ew ⇒ Object
(also: #h)
Returns the value of attribute ew.
-
#ns ⇒ Object
(also: #v)
Returns the value of attribute ns.
-
#nsw ⇒ Object
Returns the value of attribute nsw.
-
#nw ⇒ Object
Returns the value of attribute nw.
-
#sw ⇒ Object
Returns the value of attribute sw.
-
#tree_fork ⇒ Object
Returns the value of attribute tree_fork.
-
#tree_tail ⇒ Object
Returns the value of attribute tree_tail.
Class Method Summary collapse
Instance Method Summary collapse
- #box_bottom(width) ⇒ Object
- #box_top(width) ⇒ Object
- #format(description) ⇒ Object
- #horizontal_line(width) ⇒ Object
- #line_with_joints(joint, *widths) ⇒ Object
- #table_bottom(*column_widths) ⇒ Object
- #table_divide(*column_widths) ⇒ Object
- #table_top(*column_widths) ⇒ Object
Methods included from MonoclePrint
Line, Output, Rectangle, Style, Text, buffer, included, library_path, stderr, stdout, version
Instance Attribute Details
#blank ⇒ Object
Returns the value of attribute blank
6 7 8 |
# File 'lib/monocle-print/graphics.rb', line 6 def blank @blank end |
#en ⇒ Object
Returns the value of attribute en
6 7 8 |
# File 'lib/monocle-print/graphics.rb', line 6 def en @en end |
#ens ⇒ Object
Returns the value of attribute ens
6 7 8 |
# File 'lib/monocle-print/graphics.rb', line 6 def ens @ens end |
#ensw ⇒ Object
Returns the value of attribute ensw
6 7 8 |
# File 'lib/monocle-print/graphics.rb', line 6 def ensw @ensw end |
#enw ⇒ Object
Returns the value of attribute enw
6 7 8 |
# File 'lib/monocle-print/graphics.rb', line 6 def enw @enw end |
#es ⇒ Object
Returns the value of attribute es
6 7 8 |
# File 'lib/monocle-print/graphics.rb', line 6 def es @es end |
#esw ⇒ Object
Returns the value of attribute esw
6 7 8 |
# File 'lib/monocle-print/graphics.rb', line 6 def esw @esw end |
#ew ⇒ Object Also known as: h
Returns the value of attribute ew
6 7 8 |
# File 'lib/monocle-print/graphics.rb', line 6 def ew @ew end |
#ns ⇒ Object Also known as: v
Returns the value of attribute ns
6 7 8 |
# File 'lib/monocle-print/graphics.rb', line 6 def ns @ns end |
#nsw ⇒ Object
Returns the value of attribute nsw
6 7 8 |
# File 'lib/monocle-print/graphics.rb', line 6 def nsw @nsw end |
#nw ⇒ Object
Returns the value of attribute nw
6 7 8 |
# File 'lib/monocle-print/graphics.rb', line 6 def nw @nw end |
#sw ⇒ Object
Returns the value of attribute sw
6 7 8 |
# File 'lib/monocle-print/graphics.rb', line 6 def sw @sw end |
#tree_fork ⇒ Object
Returns the value of attribute tree_fork
6 7 8 |
# File 'lib/monocle-print/graphics.rb', line 6 def tree_fork @tree_fork end |
#tree_tail ⇒ Object
Returns the value of attribute tree_tail
6 7 8 |
# File 'lib/monocle-print/graphics.rb', line 6 def tree_tail @tree_tail end |
Class Method Details
.define(name, *parts) ⇒ Object
31 32 33 34 |
# File 'lib/monocle-print/graphics.rb', line 31 def self.define( name, *parts ) parts.map! { | p | Line( p ).freeze } NAMED_STYLES[ name.to_s ] = new( *parts ).freeze end |
.styles ⇒ Object
27 28 29 |
# File 'lib/monocle-print/graphics.rb', line 27 def self.styles NAMED_STYLES.keys end |
Instance Method Details
#box_bottom(width) ⇒ Object
71 72 73 |
# File 'lib/monocle-print/graphics.rb', line 71 def box_bottom( width ) format( "<ne><ew:#{ width }><nw>" ) end |
#box_top(width) ⇒ Object
67 68 69 |
# File 'lib/monocle-print/graphics.rb', line 67 def box_top( width ) format( "<se><ew:#{ width }><sw>" ) end |
#format(description) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/monocle-print/graphics.rb', line 54 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
63 64 65 |
# File 'lib/monocle-print/graphics.rb', line 63 def horizontal_line( width ) ew.tile( width ) end |
#line_with_joints(joint, *widths) ⇒ Object
87 88 89 |
# File 'lib/monocle-print/graphics.rb', line 87 def line_with_joints( joint, *widths ) widths.map { | w | horizontal_line( w ) }.join( joint ) end |
#table_bottom(*column_widths) ⇒ Object
83 84 85 |
# File 'lib/monocle-print/graphics.rb', line 83 def table_bottom( *column_widths ) sw + line_with_joints( enw, column_widths ) + se end |
#table_divide(*column_widths) ⇒ Object
79 80 81 |
# File 'lib/monocle-print/graphics.rb', line 79 def table_divide( *column_widths ) ens + line_with_joints( ensw, column_widths ) + nsw end |
#table_top(*column_widths) ⇒ Object
75 76 77 |
# File 'lib/monocle-print/graphics.rb', line 75 def table_top( *column_widths ) nw + line_with_joints( esw, column_widths ) + ne end |