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.



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

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

Instance Attribute Details

#rangeObject

: Range(Int32, Int32)



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

def range
  @range
end

#stringObject

: String



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

def string
  @string
end

Instance Method Details

#==(other) ⇒ Object



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

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

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/kleene/kleene.rb', line 83

def eql?(other)
  self == other
end

#textObject



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

def text
  @string[@range]
end

#to_sObject



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

def to_s
  text
end