Class: Zoom::Cache::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/zoom/cache/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, grep_like_tags)
    @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 (grep_like_tags)
        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

#contentsObject (readonly)

Returns the value of attribute contents.



2
3
4
# File 'lib/zoom/cache/result.rb', line 2

def contents
  @contents
end

#filenameObject (readonly)

Returns the value of attribute filename.



3
4
5
# File 'lib/zoom/cache/result.rb', line 3

def filename
  @filename
end

#linenoObject (readonly)

Returns the value of attribute lineno.



4
5
6
# File 'lib/zoom/cache/result.rb', line 4

def lineno
  @lineno
end

#matchObject (readonly)

Returns the value of attribute match.



5
6
7
# File 'lib/zoom/cache/result.rb', line 5

def match
  @match
end

#tagObject (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

Returns:

  • (Boolean)


8
9
10
# File 'lib/zoom/cache/result.rb', line 8

def grep_like?
    return @grep_like
end

#profile_nameObject



45
46
47
# File 'lib/zoom/cache/result.rb', line 45

def profile_name
    return @cache.profile_name
end

#pwdObject



49
50
51
# File 'lib/zoom/cache/result.rb', line 49

def pwd
    return @cache.pwd
end