class Suffix
Attributes
owner[R]
Public Class Methods
of(str)
click to toggle source
# File lib/adlint/prelude.rb, line 214 def self.of(str) str.length.times.map { |idx| new(str, idx) } end
Private Class Methods
new(owner, idx)
click to toggle source
# File lib/adlint/prelude.rb, line 218 def initialize(owner, idx) @owner = owner @index = idx end
Public Instance Methods
<=>(rhs)
click to toggle source
# File lib/adlint/prelude.rb, line 244 def <=>(rhs) self.to_s <=> rhs.to_s end
common_prefix_length(rhs)
click to toggle source
# File lib/adlint/prelude.rb, line 236 def common_prefix_length(rhs) to_s.chars.zip(rhs.to_s.chars).take_while { |lch, rch| lch == rch }.size end
lhs?()
click to toggle source
# File lib/adlint/prelude.rb, line 224 def lhs? subclass_responsibility end
prefix(len)
click to toggle source
# File lib/adlint/prelude.rb, line 240 def prefix(len) Substring.new(@owner, @index, len) end
rhs?()
click to toggle source
# File lib/adlint/prelude.rb, line 228 def rhs? !lhs? end
same_owner?(rhs)
click to toggle source
# File lib/adlint/prelude.rb, line 232 def same_owner?(rhs) @owner.equal?(rhs.owner) end
to_s()
click to toggle source
# File lib/adlint/prelude.rb, line 248 def to_s @owner.slice(@index..-1) end