Class: Zoom::Cache::Result
- Inherits:
-
Object
- Object
- Zoom::Cache::Result
- Defined in:
- lib/zoom/cache/result.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#lineno ⇒ Object
readonly
Returns the value of attribute lineno.
-
#match ⇒ Object
readonly
Returns the value of attribute match.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Instance Method Summary collapse
- #grep_like? ⇒ Boolean
-
#initialize(tag, contents, cache, grep_like_tags) ⇒ Result
constructor
A new instance of Result.
- #profile_name ⇒ Object
- #pwd ⇒ Object
Constructor Details
#initialize(tag, contents, cache, grep_like_tags) ⇒ Result
Returns a new instance of Result.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/zoom/cache/result.rb', line 12 def initialize(tag, contents, cache, ) @cache = cache @contents = contents.unpack("C*").pack("U*").gsub( /([\u0080-\u00ff]+)/, "\\1".dump[1..-2] ) @filename = nil @grep_like = false @lineno = nil @match = nil @tag = tag if () case @contents when /^Binary file (.+) matches\.$/ @contents.match(/^Binary file (.+) matches\.$/) do |m| next if (m.nil?) @filename = "Binary file" @contents = m[1] end when /^([^:]+)[:-](\d+)[:-](.*)$/ @contents.match(/^([^:]+)[:-](\d+)[:-](.*)$/) do |m| next if (m.nil?) @grep_like = true @filename = m[1].gsub(/^\.\//, "") @lineno = m[2] @match = m[3] end end end end |
Instance Attribute Details
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
2 3 4 |
# File 'lib/zoom/cache/result.rb', line 2 def contents @contents end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
3 4 5 |
# File 'lib/zoom/cache/result.rb', line 3 def filename @filename end |
#lineno ⇒ Object (readonly)
Returns the value of attribute lineno.
4 5 6 |
# File 'lib/zoom/cache/result.rb', line 4 def lineno @lineno end |
#match ⇒ Object (readonly)
Returns the value of attribute match.
5 6 7 |
# File 'lib/zoom/cache/result.rb', line 5 def match @match end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
6 7 8 |
# File 'lib/zoom/cache/result.rb', line 6 def tag @tag end |
Instance Method Details
#grep_like? ⇒ Boolean
8 9 10 |
# File 'lib/zoom/cache/result.rb', line 8 def grep_like? return @grep_like end |
#profile_name ⇒ Object
45 46 47 |
# File 'lib/zoom/cache/result.rb', line 45 def profile_name return @cache.profile_name end |
#pwd ⇒ Object
49 50 51 |
# File 'lib/zoom/cache/result.rb', line 49 def pwd return @cache.pwd end |