Sha256: 58e5cbba0f0a7c0353a39214b772529b467995ed5257fd46b5eb194fb870f13f
Contents?: true
Size: 1.09 KB
Versions: 5
Compression:
Stored size: 1.09 KB
Contents
# -*- coding: utf-8 -*- module Spacy class TextLine include Comparable def initialize (str = nil) @str = '' insert str, 0 if str end def insert (str, pos) raise RangeError unless 0 <= pos && pos <= last str = str.to_s raise ArgumentError, "'str' has new-line char(s)." if str =~ /\r|\n/ @str.insert pos, str self end def erase (first, last = nil) last = first + 1 unless last first, last = last, first unless first < last raise RangeError unless 0 <= first && last <= self.last @str[first...last] = '' if first != last self end def concat (str) insert str, last end alias << concat def last () @str.size end def ncolumn () last + 1 end def to_s () @str end def to_textline () self end def [] (*args) @str.[](*args) end def []= (*args) @str.[]=(*args) end def <=> (obj) to_s <=> obj.to_s end def inspect () "#<TextLine '#{@str}'>" end end# TextLine end# Spacy
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
spacy-0.1.9 | lib/spacy/textline.rb |
spacy-0.1.8 | lib/spacy/textline.rb |
spacy-0.1.6 | lib/spacy/textline.rb |
spacy-0.1.5 | lib/spacy/textline.rb |
spacy-0.1.4 | lib/spacy/textline.rb |