Class: Guard::Watcher::Pattern::MatchResult

Inherits:
Object
  • Object
show all
Defined in:
lib/guard/watcher/pattern/match_result.rb

Instance Method Summary collapse

Constructor Details

#initialize(match_result, original_value) ⇒ MatchResult

Returns a new instance of MatchResult


5
6
7
8
# File 'lib/guard/watcher/pattern/match_result.rb', line 5

def initialize(match_result, original_value)
  @match_result = match_result
  @original_value = original_value
end

Instance Method Details

#[](index) ⇒ Object


10
11
12
13
14
# File 'lib/guard/watcher/pattern/match_result.rb', line 10

def [](index)
  return @match_result[index] if index.is_a?(Symbol)
  return @original_value if index.zero?
  @match_result.to_a[index]
end