Module: MonoclePrint::Presentation

Includes:
MonoclePrint
Included in:
Layout, List, Table
Defined in:
lib/monocle-print/presentation.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

ALIGNMENTS =
[ :left, :right, :center ]

Constants included from MonoclePrint

COLOR_ESCAPE, FOUR_BYTES, MULTIBYTE_CHARACTER, ONE_BYTE, THREE_BYTES, 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, library_path, stderr, stdout, version

Instance Attribute Details

#max_widthObject



78
79
80
# File 'lib/monocle-print/presentation.rb', line 78

def max_width
  @max_width or @owner && @owner.max_width or output.width
end

#ownerObject

Returns the value of attribute owner.



14
15
16
# File 'lib/monocle-print/presentation.rb', line 14

def owner
  @owner
end

Class Method Details

.included(klass) ⇒ Object



9
10
11
12
# File 'lib/monocle-print/presentation.rb', line 9

def self.included( klass )
  super
  klass.extend( ClassMethods )
end

Instance Method Details

#alignment(value = nil) ⇒ Object



31
32
33
34
# File 'lib/monocle-print/presentation.rb', line 31

def alignment( value = nil )
  value and self.alignment = value
  @alignment or @owner ? @owner.alignment : :left
end

#alignment=(value) ⇒ Object



36
37
38
39
40
# File 'lib/monocle-print/presentation.rb', line 36

def alignment= value
  ALIGNMENTS.member?( value = value.to_sym ) or
    raise( ArgumentError, "unkown alignment: %p" % value )
  @alignment = value
end

#heightObject



68
69
70
# File 'lib/monocle-print/presentation.rb', line 68

def height
  @height or calculate_height
end

#outputObject



82
83
84
# File 'lib/monocle-print/presentation.rb', line 82

def output
  @output ||= ( @owner and @owner.output or OutputDevice.stdout )
end

#output=(io) ⇒ Object



86
87
88
# File 'lib/monocle-print/presentation.rb', line 86

def output=( io )
  @output = io.nil? ? io : Output( io )
end

#render(output = @output) ⇒ Object



51
52
53
54
55
56
57
58
59
60
# File 'lib/monocle-print/presentation.rb', line 51

def render( output = @output )
  if output
    render_content( output )
    return output
  else
    OutputDevice.buffer do | out |
      render_content( out )
    end
  end
end

#style(value = nil) ⇒ Object



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

def style( value = nil )
  value and self.style = value
  @style or @owner ? @owner.style : Graphics.default
end

#style=(value) ⇒ Object



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

def style= value
  @style = Style( value )
end

#to_sObject



62
63
64
65
66
# File 'lib/monocle-print/presentation.rb', line 62

def to_s
  OutputDevice.buffer do | out |
    render_content( out )
  end
end

#widthObject



72
73
74
# File 'lib/monocle-print/presentation.rb', line 72

def width
  @width or calculate_width
end