Class: Decode::Syntax::Match

Inherits:
Object
  • Object
show all
Defined in:
lib/decode/syntax/match.rb

Direct Known Subclasses

Link

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(range) ⇒ Match

Returns a new instance of Match.



9
10
11
# File 'lib/decode/syntax/match.rb', line 9

def initialize(range)
	@range = range
end

Instance Attribute Details

#rangeObject (readonly)

Returns the value of attribute range.



13
14
15
# File 'lib/decode/syntax/match.rb', line 13

def range
  @range
end

Instance Method Details

#<=>(other) ⇒ Object



19
20
21
# File 'lib/decode/syntax/match.rb', line 19

def <=> other
	@range.min <=> other.range.min
end

#apply(output, rewriter) ⇒ Object



15
16
17
# File 'lib/decode/syntax/match.rb', line 15

def apply(source)
	return source[range]
end

#offsetObject



23
24
25
# File 'lib/decode/syntax/match.rb', line 23

def offset
	@range.min
end

#sizeObject



27
28
29
# File 'lib/decode/syntax/match.rb', line 27

def size
	@range.size
end