Sha256: 3f3a76d6817523bd28142206caad1170d30ff6d6d355bdc41d5c7765c93ac07e

Contents?: true

Size: 1023 Bytes

Versions: 6

Compression:

Stored size: 1023 Bytes

Contents

# encoding: utf-8

# Copyright (C) 2016 Mikio Ikoma

require 'regextest/common'
require 'regextest/regex-option'

# Anchor class
module Regextest::Front::Anchor
  class Anchor
    include Regextest::Common
    include Regextest::Common
    @@id = 0   # a class variable for generating unique name of element
      
    # Constructor
    def initialize(type, val)
      TstLog("Anchor: value:#{val}")
      @type = type
      @value = val[0] || ""
      @offset = val[1] || -1
      @length = val[2] || 0
    end
    
    attr_reader :offset, :length
    
    # set options
    def set_options(options)
      TstLog("Anchor set_options: #{options[:reg_options].inspect}");
    end
    
    # transform to json format
    def json
      @@id += 1
      "{" +
         "\"type\": \"#{@type}\", \"id\": \"A#{@@id}\", \"value\": \"#{@value}\", " +
         "\"offset\": #{@offset}, \"length\": #{@length}" +
      "}"
    end
  end
end

# Test suite (execute when this file is specified in command line)
if __FILE__ == $0 
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
regextest-0.1.8 lib/regextest/front/anchor.rb
regextest-0.1.6 lib/regextest/front/anchor.rb
regextest-0.1.5 lib/regextest/front/anchor.rb
regextest-0.1.4 lib/regextest/front/anchor.rb
regextest-0.1.3 lib/regextest/front/anchor.rb
regextest-0.1.2 lib/regextest/front/anchor.rb