Class: MonoclePrint::Table::Member
- Inherits:
-
Object
- Object
- MonoclePrint::Table::Member
show all
- Includes:
- Enumerable, MonoclePrint
- Defined in:
- lib/monocle-print/table/members.rb
Constant Summary
COLOR_ESCAPE, FOUR_BYTES, MULTIBYTE_CHARACTER, ONE_BYTE, MonoclePrint::THREE_BYTES, MonoclePrint::TWO_BYTES, VERSION
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Line, Output, Rectangle, Style, Text, buffer, included, library_path, stderr, stdout, version
Constructor Details
#initialize(table, *args) ⇒ Member
Returns a new instance of Member.
30
31
32
33
34
35
36
37
|
# File 'lib/monocle-print/table/members.rb', line 30
def initialize( table, *args )
@table = table
@before = nil
@after = nil
@disabled = false
block_given? and yield( self )
initialize!( *args )
end
|
Class Attribute Details
.member_name ⇒ Object
Returns the value of attribute member_name.
11
12
13
|
# File 'lib/monocle-print/table/members.rb', line 11
def member_name
@member_name
end
|
Instance Attribute Details
#after ⇒ Object
Returns the value of attribute after.
27
28
29
|
# File 'lib/monocle-print/table/members.rb', line 27
def after
@after
end
|
#before ⇒ Object
Returns the value of attribute before.
27
28
29
|
# File 'lib/monocle-print/table/members.rb', line 27
def before
@before
end
|
#table ⇒ Object
Returns the value of attribute table.
26
27
28
|
# File 'lib/monocle-print/table/members.rb', line 26
def table
@table
end
|
Class Method Details
.define(member_name, sup = self, &body) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/monocle-print/table/members.rb', line 12
def define( member_name, sup = self, &body )
klass =
Class.new( sup ) do
@member_name = member_name
class_eval( &body )
end
define_method( "#{ member_name }!" ) do |*args|
klass.new( @table, *args ) { |m| link( m ) }.tail
end
return( klass )
end
|
Instance Method Details
#columns ⇒ Object
96
97
98
|
# File 'lib/monocle-print/table/members.rb', line 96
def columns
table.columns
end
|
#disable ⇒ Object
57
58
59
|
# File 'lib/monocle-print/table/members.rb', line 57
def disable
@disabled = true
end
|
#disabled? ⇒ Boolean
69
70
71
|
# File 'lib/monocle-print/table/members.rb', line 69
def disabled?
@disabled
end
|
#each ⇒ Object
48
49
50
51
52
53
54
55
|
# File 'lib/monocle-print/table/members.rb', line 48
def each
block_given? or return( enum_for( __method__ ) )
node = self
begin
yield( node )
node = node.after
end while( node )
end
|
#enable ⇒ Object
61
62
63
|
# File 'lib/monocle-print/table/members.rb', line 61
def enable
@disabled = false
end
|
#enabled? ⇒ Boolean
65
66
67
|
# File 'lib/monocle-print/table/members.rb', line 65
def enabled?
not disabled?
end
|
#first? ⇒ Boolean
73
74
75
|
# File 'lib/monocle-print/table/members.rb', line 73
def first?
@before.nil?
end
|
#initialize! ⇒ Object
39
40
41
|
# File 'lib/monocle-print/table/members.rb', line 39
def initialize!( * )
end
|
#inspect(*args) ⇒ Object
43
44
45
46
|
# File 'lib/monocle-print/table/members.rb', line 43
def inspect( *args )
content = args.map! { |a| a.inspect }.join(', ')
"#{self.class.member_name}(#{content})"
end
|
#last? ⇒ Boolean
77
78
79
|
# File 'lib/monocle-print/table/members.rb', line 77
def last?
@after.nil?
end
|
#link(item) ⇒ Object
81
82
83
84
|
# File 'lib/monocle-print/table/members.rb', line 81
def link( item )
after, @after, item.before = @after, item, self
after ? item.link( after ) : item
end
|
#render(out, style) ⇒ Object
92
93
94
|
# File 'lib/monocle-print/table/members.rb', line 92
def render( out, style )
render!( out, style ) unless disabled?
end
|
#tail ⇒ Object
100
101
102
|
# File 'lib/monocle-print/table/members.rb', line 100
def tail
@after ? @after.tail : self
end
|
#unlink ⇒ Object
86
87
88
89
90
|
# File 'lib/monocle-print/table/members.rb', line 86
def unlink
@before and @before.after = nil
@before = nil
return( self )
end
|