class Regextest::Front::Repeatable::Repeatable
Attributes
length[R]
offset[R]
Public Class Methods
new(value)
click to toggle source
Constructor
# File lib/regextest/front/repeatable.rb, line 16 def initialize(value) TstLog("Repeatable: #{value}") @value = value @offset = value.offset @length = value.length @quant = [] end
Public Instance Methods
json()
click to toggle source
transform to json format
# File lib/regextest/front/repeatable.rb, line 43 def json json_string = "" @quant.each do | current | @@id += 1 json_string += "{\"type\": \"LEX_REPEAT\", " + " \"id\": \"m#{@@id}\", " + " \"value\": " end json_string += @value.json if @quant.size > 0 work = @quant.map do | current | repeat_option = [] repeat_option.push "reluctant" if current.is_reluctant? repeat_option.push "possessive" if current.is_possessive? " \"offset\": #{@offset}, " + " \"length\": #{@length}, " + " \"min_repeat\": #{current.min_value}, " + " \"max_repeat\": #{current.max_value}, " + " \"repeat_option\": #{repeat_option} " + "}" end json_string += ", " + work.join(", ") end json_string end
set_options(options)
click to toggle source
set options
# File lib/regextest/front/repeatable.rb, line 36 def set_options(options) TstLog("Repeatable set_options: #{options[:reg_options].inspect}"); @value.set_options(options) self end
set_quant(quant_value)
click to toggle source
add quantifier
# File lib/regextest/front/repeatable.rb, line 27 def set_quant(quant_value) quant = quant_value[0] @length += quant_value[2] TstLog("Repeatable quant: #{quant_value}") @quant.push Repeat.new(quant) self end