Class: Regextest::Front::Range::TRange
- Inherits:
-
Object
- Object
- Regextest::Front::Range::TRange
- Includes:
- Common
- Defined in:
- lib/regextest/front/range.rb
Constant Summary collapse
- @@id =
a class variable for generating unique name of element
0
Constants included from Common
Common::TstConstDebug, Common::TstConstRecursionMax, Common::TstConstRepeatMax, Common::TstConstRetryMax, Common::TstConstRetryMaxSecond, Common::TstConstTimeout, Common::TstConstUnicodeCharSet, Common::TstFixnumMax
Instance Attribute Summary collapse
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
Instance Method Summary collapse
-
#enumerate ⇒ Object
enumerate.
-
#initialize(letter_begin, letter_end = nil) ⇒ TRange
constructor
Constructor.
-
#json ⇒ Object
transform to json format (using codepoints of Unicode).
-
#parse_letter(letter) ⇒ Object
parse letter.
-
#set_options(options) ⇒ Object
set options.
Methods included from Common
#TstLog, #TstMdPrint, #TstRand, #TstShuffle, #is_random?, #reset_random_called
Constructor Details
#initialize(letter_begin, letter_end = nil) ⇒ TRange
Constructor
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/regextest/front/range.rb', line 15 def initialize(letter_begin, letter_end = nil) TstLog("TRange: #{letter_begin}-#{letter_end}") = nil @begin = parse_letter(letter_begin) if letter_end @end = parse_letter(letter_end) else @end = @begin end @offset = -1 # not used in this class @length = -1 # not used in this class end |
Instance Attribute Details
#length ⇒ Object (readonly)
Returns the value of attribute length.
29 30 31 |
# File 'lib/regextest/front/range.rb', line 29 def length @length end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
29 30 31 |
# File 'lib/regextest/front/range.rb', line 29 def offset @offset end |
Instance Method Details
#enumerate ⇒ Object
enumerate
46 47 48 |
# File 'lib/regextest/front/range.rb', line 46 def enumerate (@begin..@end).to_a end |
#json ⇒ Object
transform to json format (using codepoints of Unicode)
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/regextest/front/range.rb', line 57 def json @@id += 1 if charset = [:reg_options].charset else charset = "d" end "{" + "\"type\": \"LEX_RANGE\", " + "\"id\": \"G#{@@id}\", " + "\"begin\": #{@begin}, " + "\"end\": #{@end}, " + "\"charset\": \"#{charset}\"" + "}" end |
#parse_letter(letter) ⇒ Object
parse letter
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/regextest/front/range.rb', line 32 def parse_letter(letter) case letter when String letter.unpack("U*")[0] when Integer letter when Regextest::Front::Letter::TLetter eval('"' + letter.value + '"').unpack("U*")[0] else raise "Internal error. invalid letter class #{letter}" end end |
#set_options(options) ⇒ Object
set options
51 52 53 54 |
# File 'lib/regextest/front/range.rb', line 51 def () TstLog("Range set_options: #{options[:reg_options].inspect}") = end |