Skip to content

Commit

Permalink
Removed class MultiMatchData
Browse files Browse the repository at this point in the history
  • Loading branch information
dichodaemon committed Mar 26, 2007
1 parent e081eff commit 43f4e9a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 54 deletions.
4 changes: 1 addition & 3 deletions ext/oregexp.c
Expand Up @@ -627,9 +627,7 @@ oregexp_scan(VALUE self, VALUE str, OnigRegion * region)
region, ONIG_OPTION_NONE);
} while ( beg >= 0);

VALUE rb_cMultiMatchData = rb_const_get(mOniguruma, rb_intern("MultiMatchData")) ;

return rb_funcall(rb_cMultiMatchData, rb_intern("new"), 2, string_str, matches) ;
return matches;
}

struct scan_packet {
Expand Down
48 changes: 0 additions & 48 deletions lib/oniguruma.rb
Expand Up @@ -319,54 +319,6 @@ def source

end

class MultiMatchData
def initialize( string, matches )
@matches = matches
@string = string
end

def position index
@matches[index].begin(0)
end

def [] ( value1, value2 = nil )
unless value2
@matches[value1]
else
@matches[value1, value2]
end
end

def begin index
@matches[index].begin(0)
end

def end index
@matches[index].end(0)
end

def length
@matches.size
end
alias size length

def offset index
[self.begin(index), self.end(index) ]
end

def string
@string.freeze
end

def to_a
@matches
end

def each &block
@matches.each &block
end
end

end
class ::MatchData
alias old_aref :[]
Expand Down
6 changes: 3 additions & 3 deletions test/test_oniguruma.rb
Expand Up @@ -202,15 +202,15 @@ def test_match_all
matches.each { |m| a << m.offset(0) }
assert_equal( [ [1,3], [5,7], [10,12] ], a)
assert_equal( 3, matches.size )
assert_equal( 10, matches.position(2) )
assert_equal( "ca", matches.string[matches.begin(1)...matches.end(1)])
assert_equal( 10, matches[2].begin( 0 ) )
assert_equal( "ca", matches[1].string[matches[1].begin( 0 )...matches[1].end( 0 )])
end

def test_scan
reg = Oniguruma::ORegexp.new( 'ca' )
a = []
matches = reg.match_all( 'ocatacachaca' ) { |m| a << m.offset(0) }
assert_kind_of(Oniguruma::MultiMatchData, matches)
#assert_kind_of(Oniguruma::MultiMatchData, matches)
assert_equal( [ [1,3], [5,7], [10,12] ], a)
end

Expand Down

0 comments on commit 43f4e9a

Please sign in to comment.