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.



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

def initialize(range)
	@range = range
end

Instance Attribute Details

#rangeObject (readonly)

Returns the value of attribute range.



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

def range
  @range
end

Instance Method Details

#<=>(other) ⇒ Object



34
35
36
# File 'lib/decode/syntax/match.rb', line 34

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

#apply(output, rewriter) ⇒ Object



30
31
32
# File 'lib/decode/syntax/match.rb', line 30

def apply(source)
	return source[range]
end

#offsetObject



38
39
40
# File 'lib/decode/syntax/match.rb', line 38

def offset
	@range.min
end

#sizeObject



42
43
44
# File 'lib/decode/syntax/match.rb', line 42

def size
	@range.size
end