Class: Kleene::MatchRef

Inherits:
Object
  • Object
show all
Defined in:
lib/kleene/kleene.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original_string, match_range) ⇒ MatchRef

Returns a new instance of MatchRef.



64
65
66
67
# File 'lib/kleene/kleene.rb', line 64

def initialize(original_string, match_range)
  @string = original_string
  @range = match_range
end

Instance Attribute Details

#rangeObject

: Range(Int32, Int32)



62
63
64
# File 'lib/kleene/kleene.rb', line 62

def range
  @range
end

#stringObject

: String



61
62
63
# File 'lib/kleene/kleene.rb', line 61

def string
  @string
end

Instance Method Details

#==(other) ⇒ Object



77
78
79
# File 'lib/kleene/kleene.rb', line 77

def ==(other)
  @string == other.string && @range == other.range
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/kleene/kleene.rb', line 81

def eql?(other)
  self == other
end

#textObject



69
70
71
# File 'lib/kleene/kleene.rb', line 69

def text
  @string[@range]
end

#to_sObject



73
74
75
# File 'lib/kleene/kleene.rb', line 73

def to_s
  text
end