Class: RandallRegExp::SpanCharClass

Inherits:
CharClass
  • Object
show all
Defined in:
lib/randall/charclass.rb

Instance Method Summary collapse

Methods inherited from CharClass

#rand

Methods included from CharSets

#all_chars, #control, #decimal_number, #graph, #letter, #lower_letter, #punctuation, #space, #upper_letter, #word, #xchar, #xdigit

Instance Method Details

#charsObject



170
171
172
173
174
175
176
177
# File 'lib/randall/charclass.rb', line 170

def chars
  @chars ||= case self.text_value
  when /([0-9a-zA-Z])\-([0-9a-zA-Z])/
    $1 <= $2 ? self.strseq($1, $2) : ''
  else
    self.text_value.split('').uniq
  end
end

#strseq(from, to) ⇒ Object



179
180
181
182
183
# File 'lib/randall/charclass.rb', line 179

def strseq(from, to)
  (to.ord - from.ord).times.map do |i|
    (from.ord + i).chr
  end
end