Module: Roebe::DisplayArray
- Extended by:
- DisplayArray
- Includes:
- Colours::E
- Included in:
- DisplayArray
- Defined in:
- lib/roebe/toplevel_methods/display_array.rb
Overview
Roebe::DisplayArray.display
Constant Summary
collapse
- DEFAULT_FORMATTER =
''
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
#
Roebe::DisplayArray[]
Simply pass the Array into this method.
#
81
82
83
|
# File 'lib/roebe/toplevel_methods/display_array.rb', line 81
def self.[](i)
display(i)
end
|
.use_colours? ⇒ Boolean
#
Roebe::DisplayArray.use_colours?
#
38
39
40
|
# File 'lib/roebe/toplevel_methods/display_array.rb', line 38
def self.use_colours?
@use_colours
end
|
Instance Method Details
#display(i, format = DEFAULT_FORMATTER, leading_padding = '') ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/roebe/toplevel_methods/display_array.rb', line 45
def display(
i,
format = DEFAULT_FORMATTER,
leading_padding = ''
)
if format.is_a? Hash
if format.has_key? :padding
leading_padding = format.delete(:padding)
end
if format.has_key? :token format = format.delete(:token)
end
end
if format.is_a? Hash format = DEFAULT_FORMATTER
end
format = DEFAULT_FORMATTER if format.nil?
if i.is_a? Array
i.each_with_index {|entry, index|
index += 1
index = index.to_s
index = index.rjust(2)
_ = leading_padding+index+format
_ = Roebe.sfancy(_) if self.use_colours?
e "#{_} #{entry}"
}
else
e i
end
end
|