Module: RandallRegExp::CharSets
- Included in:
- CharClass
- Defined in:
- lib/randall/charclass.rb
Overview
:nodoc: all
Instance Method Summary collapse
- #all_chars ⇒ Object (also: #ascii)
- #control ⇒ Object
- #decimal_number ⇒ Object (also: #digit)
- #graph ⇒ Object
- #letter ⇒ Object
- #lower_letter ⇒ Object
- #punctuation ⇒ Object
- #space ⇒ Object
- #strseq(from, to) ⇒ Object
- #upper_letter ⇒ Object
- #word ⇒ Object
- #xchar ⇒ Object
- #xdigit ⇒ Object
Instance Method Details
#all_chars ⇒ Object Also known as: ascii
16 17 18 |
# File 'lib/randall/charclass.rb', line 16 def all_chars @@ascii ||= strseq(0, 0x7f) end |
#control ⇒ Object
25 26 27 |
# File 'lib/randall/charclass.rb', line 25 def control @@control ||= strseq(0, 0x1f) << 0x7f end |
#decimal_number ⇒ Object Also known as: digit
29 30 31 |
# File 'lib/randall/charclass.rb', line 29 def decimal_number @@decimal_number ||= (0..9).to_a.map(&:to_s) end |
#graph ⇒ Object
21 22 23 |
# File 'lib/randall/charclass.rb', line 21 def graph @@graph ||= strseq(0x21, 0x7e) end |
#letter ⇒ Object
44 45 46 |
# File 'lib/randall/charclass.rb', line 44 def letter @@letter ||= self.lower_letter + self.upper_letter end |
#lower_letter ⇒ Object
34 35 36 37 38 |
# File 'lib/randall/charclass.rb', line 34 def lower_letter @@lower_letter ||= 26.times.map do |i| ('a'.ord + i).chr end end |
#punctuation ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/randall/charclass.rb', line 52 def punctuation # CHECK: which chars belong to this set? @@punct ||= ['!', "\"", '#', #'$', '%', '&', "'", '(', ')', '*', #'+', '-', '.', '/', ':', ';', '<', #'=', '>', '?', '@', '[', '\\', ']', #'^', '_', #'`', '{', #'|', '}', #'~' ] end |
#space ⇒ Object
48 49 50 |
# File 'lib/randall/charclass.rb', line 48 def space @@space ||= ["\s", "\t", "\r", "\n", "\v", "\f"] end |
#strseq(from, to) ⇒ Object
12 13 14 |
# File 'lib/randall/charclass.rb', line 12 def strseq(from, to) (from..to).map(&:chr) end |
#upper_letter ⇒ Object
40 41 42 |
# File 'lib/randall/charclass.rb', line 40 def upper_letter @@upper_letter ||= self.lower_letter.map(&:upcase) end |
#word ⇒ Object
74 75 76 |
# File 'lib/randall/charclass.rb', line 74 def word @@word ||= self.letter + self.digit << '_' end |
#xchar ⇒ Object
65 66 67 68 |
# File 'lib/randall/charclass.rb', line 65 def xchar c = ['a', 'b', 'c', 'd', 'e'] c += c.map(&:upcase) end |
#xdigit ⇒ Object
70 71 72 |
# File 'lib/randall/charclass.rb', line 70 def xdigit @@xdigit ||= self.digit + self.xchar end |