Class: ZSteg::Result::Text
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#offset ⇒ Object
Returns the value of attribute offset
25
26
27
|
# File 'lib/zsteg/result.rb', line 25
def offset
@offset
end
|
#text ⇒ Object
Returns the value of attribute text
25
26
27
|
# File 'lib/zsteg/result.rb', line 25
def text
@text
end
|
Class Method Details
.from_matchdata(m) ⇒ Object
47
48
49
|
# File 'lib/zsteg/result.rb', line 47
def self.from_matchdata m
self.new m[0], m.begin(0)
end
|
Instance Method Details
#one_char? ⇒ Boolean
26
27
28
29
30
|
# File 'lib/zsteg/result.rb', line 26
def one_char?
(text =~ /\A(.)\1+\Z/m) == 0
rescue text.chars.to_a.uniq.size == 1 end
|
#to_s ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/zsteg/result.rb', line 32
def to_s
"text: ".gray +
if one_char?
"[#{text[0].inspect} repeated #{text.size} times]".gray
elsif offset == 0
text.inspect.bright_red
elsif text.size > 10 && text[' '] && text =~ /\A[a-z0-9 .,:!_-]+\Z/i
text.inspect.bright_red
else
text.inspect
end
end
|