Class: ZSteg::FileCmd::Result
- Inherits:
-
Struct
- Object
- Struct
- ZSteg::FileCmd::Result
- Defined in:
- lib/zsteg/file_cmd.rb
Constant Summary collapse
- COLORMAP_TEXT =
{ /DBase 3 data/i => :gray }
- COLORMAP_WORD =
{ /bitmap|jpeg|pdf|zip|rar|7-?z/i => :bright_red, }
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data
28 29 30 |
# File 'lib/zsteg/file_cmd.rb', line 28 def data @data end |
#title ⇒ Object
Returns the value of attribute title
28 29 30 |
# File 'lib/zsteg/file_cmd.rb', line 28 def title @title end |
Instance Method Details
#colorize(color) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/zsteg/file_cmd.rb', line 56 def colorize color if color == :gray # gray whole string "file: #{title}".send(color) else "file: " + title.send(color) end end |
#to_s ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/zsteg/file_cmd.rb', line 36 def to_s if title[/UTF-8 Unicode text/i] begin t = data.force_encoding("UTF-8").encode("UTF-32LE").encode("UTF-8") rescue t = data.force_encoding('binary') end return "utf8: " + t end COLORMAP_TEXT.each do |re,color| return colorize(color) if title[re] end title.downcase.split.each do |word| COLORMAP_WORD.each do |re,color| return colorize(color) if title.index(re) == 0 end end colorize(:yellow) end |