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) ⇒ Result

Returns a new instance of Result.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/zoom/cache/result.rb', line 16

def initialize(tag, contents, cache)
    @cache = cache
    @contents = contents
    @filename = nil
    @grep_like = false
    @lineno = nil
    @match = nil
    @tag = tag

    @contents.unpack("C*").pack("U*").gsub(
        /([\u0080-\u00ff]+)/,
        "\\1".dump[1..-2]
    ).match(/^([^:]+):(\d+)[:-](.*)/) do |m|
        next if (m.nil?)

        @grep_like = true
        @filename = m[1]
        @lineno = m[2]
        @match = m[3]
    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

#args ⇒ Object



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

def args
    return @cache.args
end

#grep_like? ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/zoom/cache/result.rb', line 12

def grep_like?
    return @grep_like
end

#paths ⇒ Object



38
39
40
# File 'lib/zoom/cache/result.rb', line 38

def paths
    return @cache.paths
end

#pattern ⇒ Object



42
43
44
# File 'lib/zoom/cache/result.rb', line 42

def pattern
    return @cache.pattern
end

#profile_name ⇒ Object



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

def profile_name
    return @cache.profile_name
end

#pwd ⇒ Object



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

def pwd
    return @cache.pwd
end