Class: Roebe::StringColourParser
- Inherits:
-
Object
- Object
- Roebe::StringColourParser
show all
- Defined in:
- lib/roebe/classes/string_colour_parser.rb
Overview
Roebe::StringColourParser
Constant Summary
collapse
- TEST_STRING =
'We found |file|3 files|_|, |dir|25 directories|_| and |symlink|7 symlinks|_| in '\
'this directory. But we must not modify |shot|.'
- ENCODING_ISO =
'ISO-8859-1'
- SHALL_WE_DEBUG =
false
Instance Method Summary
collapse
Constructor Details
#initialize(test_this_string = nil, run_already = true) ⇒ StringColourParser
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/roebe/classes/string_colour_parser.rb', line 45
def initialize(
test_this_string = nil,
run_already = true
)
reset
set_string(
test_this_string
)
run if run_already
end
|
Instance Method Details
#output_string ⇒ Object
Also known as:
report
96
97
98
|
# File 'lib/roebe/classes/string_colour_parser.rb', line 96
def output_string
e @string
end
|
#parse_string(i) ⇒ Object
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/roebe/classes/string_colour_parser.rb', line 110
def parse_string(i)
_ = ''.dup splitted = i.split('|') pp splitted if @debug
splitted.each { |char|
if @debug
e "The character is now: #{char}"
end
case char when '_' _ << ::Colours.rev()
when 'fancy','fa'
_ << ::Colours.sfancy()
when 'important','imp','simp'
_ << ::Colours.simportant()
when 'file','fi'
_ << ::Colours.sfile()
when 'dir','directory'
_ << ::Colours.sdir()
when 'symlink'
_ << ::Colours.ssymlink()
else _ << char
end
}
return _
end
|
59
60
61
62
63
64
|
# File 'lib/roebe/classes/string_colour_parser.rb', line 59
def reset
@debug = SHALL_WE_DEBUG
end
|
69
70
71
|
# File 'lib/roebe/classes/string_colour_parser.rb', line 69
def result
@string
end
|
144
145
146
147
148
149
150
|
# File 'lib/roebe/classes/string_colour_parser.rb', line 144
def run
split_up_string
if @debug
e 'The string is now: '+@string
pp @string
end
end
|
#set_string(i = TEST_STRING) ⇒ Object
76
77
78
79
80
81
82
83
84
|
# File 'lib/roebe/classes/string_colour_parser.rb', line 76
def set_string(i = TEST_STRING)
i = i.first if i.is_a? Array
case i
when :test_string, :default, nil
i = TEST_STRING
end
i = i.to_s.dup
@string = i
end
|
#split_up_string ⇒ Object
89
90
91
|
# File 'lib/roebe/classes/string_colour_parser.rb', line 89
def split_up_string
@string = parse_string(@string)
end
|
#string? ⇒ Boolean
Also known as:
string
103
104
105
|
# File 'lib/roebe/classes/string_colour_parser.rb', line 103
def string?
@string
end
|