Class: MonoclePrint::Table::Segments

Inherits:
Struct
  • Object
show all
Includes:
MonoclePrint
Defined in:
lib/monocle-print/table/segments.rb,
lib/monocle-print/table/segments.rb

Constant Summary

Constants included from MonoclePrint

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from MonoclePrint

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

Instance Attribute Details

#footObject

Returns the value of attribute foot

Returns:

  • (Object)

    the current value of foot



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

def foot
  @foot
end

#headObject

Returns the value of attribute head

Returns:

  • (Object)

    the current value of head



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

def head
  @head
end

#rowObject

Returns the value of attribute row

Returns:

  • (Object)

    the current value of row



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

def row
  @row
end

#row_dividerObject

Returns the value of attribute row_divider

Returns:

  • (Object)

    the current value of row_divider



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

def row_divider
  @row_divider
end

#sectionObject

Returns the value of attribute section

Returns:

  • (Object)

    the current value of section



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

def section
  @section
end

#section_closeObject

Returns the value of attribute section_close

Returns:

  • (Object)

    the current value of section_close



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

def section_close
  @section_close
end

#section_openObject

Returns the value of attribute section_open

Returns:

  • (Object)

    the current value of section_open



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

def section_open
  @section_open
end

#title_dividerObject

Returns the value of attribute title_divider

Returns:

  • (Object)

    the current value of title_divider



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

def title_divider
  @title_divider
end

#title_rowObject

Returns the value of attribute title_row

Returns:

  • (Object)

    the current value of title_row



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

def title_row
  @title_row
end

Class Method Details

.default_filling(style) ⇒ Object



15
16
17
18
# File 'lib/monocle-print/table/segments.rb', line 15

def self.default_filling( style )
  fill = style.new.dup
  new( fill, nil, fill, nil, fill, nil, fill, fill, fill )
end

.default_joints(style) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/monocle-print/table/segments.rb', line 20

def self.default_joints( style )
  head = style.format( "<h><hd><h>" )
  row  = style.format( " <v> " )
  div  = style.format( "<h><hv><h>" )
  foot = style.format( "<h><hu><h>" )
  
  new( head, row, div, row, div, nil, foot, head, foot )
end

.default_left_edge(style) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/monocle-print/table/segments.rb', line 29

def self.default_left_edge( style )
  head = style.format( "<dr><h>" )
  row  = style.format( "<v> " )
  div  = style.format( "<vr><h>" )
  foot = style.format( "<ur><h>" )
  new( head, row, div, row, div, row, div, div, foot )
end

.default_right_edge(style) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/monocle-print/table/segments.rb', line 37

def self.default_right_edge( style )
  head = style.format( "<h><dl>" )
  row  = style.format( " <v>" )
  div  = style.format( "<h><vl>" )
  foot = style.format( "<h><ul>" )
  new( head, row, div, row, div, row, div, div, foot )
end

Instance Method Details

#mask(inclusion_settings) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/monocle-print/table/segments.rb', line 45

def mask( inclusion_settings )
  masked = self.class.new
  each_pair do | name, text |
    if text and inclusion_settings[ name ]
      masked[ name ] = text
    end
  end
  return( masked )
end

#width(inclusion_mask = nil) ⇒ Object



55
56
57
58
# File 'lib/monocle-print/table/segments.rb', line 55

def width( inclusion_mask = nil )
  inclusion_mask and return( self.mask( inclusion_mask ).width )
  return( map { |text| text ? text.width : 0 }.max )
end