Class: Muwu::Destination
- Inherits:
-
Object
show all
- Includes:
- Muwu
- Defined in:
- lib/muwu/destination/destination.rb
Constant Summary
collapse
- MARGIN =
' '
Constants included
from Muwu
GEM_HOME_LIB, GEM_HOME_LIB_MUWU, VERSION
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Muwu
debug, read
Constructor Details
Returns a new instance of Destination.
22
23
24
25
|
# File 'lib/muwu/destination/destination.rb', line 22
def initialize
@margin_depth = 0
@output = nil
end
|
Instance Attribute Details
#margin_current ⇒ Object
Returns the value of attribute margin_current.
8
9
10
|
# File 'lib/muwu/destination/destination.rb', line 8
def margin_current
@margin_current
end
|
#output_class ⇒ Object
Returns the value of attribute output_class.
8
9
10
|
# File 'lib/muwu/destination/destination.rb', line 8
def output_class
@output_class
end
|
#output_filename ⇒ Object
Returns the value of attribute output_filename.
8
9
10
|
# File 'lib/muwu/destination/destination.rb', line 8
def output_filename
@output_filename
end
|
#output_working_directory ⇒ Object
Returns the value of attribute output_working_directory.
8
9
10
|
# File 'lib/muwu/destination/destination.rb', line 8
def output_working_directory
@output_working_directory
end
|
Instance Method Details
#filename ⇒ Object
42
43
44
|
# File 'lib/muwu/destination/destination.rb', line 42
def filename
@output_filename
end
|
#inspect ⇒ Object
28
29
30
|
# File 'lib/muwu/destination/destination.rb', line 28
def inspect
["#{self.to_s}", "{", inspect_instance_variables, "}"].join(' ')
end
|
#inspect_instance_variables ⇒ Object
33
34
35
|
# File 'lib/muwu/destination/destination.rb', line 33
def inspect_instance_variables
self.instance_variables.map { |v| "#{v}=#{instance_variable_get(v).inspect}" }.join(", ")
end
|
#margin_dec ⇒ Object
47
48
49
|
# File 'lib/muwu/destination/destination.rb', line 47
def margin_dec
@margin_depth = @margin_depth.to_i - 1
end
|
#margin_inc ⇒ Object
52
53
54
|
# File 'lib/muwu/destination/destination.rb', line 52
def margin_inc
@margin_depth = @margin_depth.to_i + 1
end
|
#margin_indent ⇒ Object
57
58
59
60
61
|
# File 'lib/muwu/destination/destination.rb', line 57
def margin_indent
margin_inc
yield
margin_dec
end
|
#margin_to_zero ⇒ Object
64
65
66
|
# File 'lib/muwu/destination/destination.rb', line 64
def margin_to_zero
@margin_depth = 0
end
|
#output_is_closed ⇒ Object
80
81
82
|
# File 'lib/muwu/destination/destination.rb', line 80
def output_is_closed
@output == nil
end
|
#output_is_opened ⇒ Object
85
86
87
|
# File 'lib/muwu/destination/destination.rb', line 85
def output_is_opened
@output != nil
end
|
#output_stream ⇒ Object
90
91
92
93
94
95
|
# File 'lib/muwu/destination/destination.rb', line 90
def output_stream
announce_open
output_open
yield
output_close
end
|
#padding_vertical(n) ⇒ Object
98
99
100
101
102
|
# File 'lib/muwu/destination/destination.rb', line 98
def padding_vertical(n)
output.print ("\n" * n)
yield
output.print ("\n" * n)
end
|
#write_inline(value) ⇒ Object
105
106
107
|
# File 'lib/muwu/destination/destination.rb', line 105
def write_inline(value)
write_value(value)
end
|
#write_inline_end(value) ⇒ Object
110
111
112
113
|
# File 'lib/muwu/destination/destination.rb', line 110
def write_inline_end(value)
write_value(value)
write_lf
end
|
#write_inline_indented(value) ⇒ Object
116
117
118
119
|
# File 'lib/muwu/destination/destination.rb', line 116
def write_inline_indented(value)
write_margin
write_value(value)
end
|
#write_lf ⇒ Object
122
123
124
|
# File 'lib/muwu/destination/destination.rb', line 122
def write_lf
output.print "\n"
end
|
#write_line(value) ⇒ Object
127
128
129
130
131
|
# File 'lib/muwu/destination/destination.rb', line 127
def write_line(value)
write_margin
write_value(value)
write_lf
end
|
#write_margin ⇒ Object
134
135
136
|
# File 'lib/muwu/destination/destination.rb', line 134
def write_margin
output.print render_current_margin
end
|
#write_value(value) ⇒ Object
139
140
141
|
# File 'lib/muwu/destination/destination.rb', line 139
def write_value(value)
output.print value
end
|