Sha256: 6abf57f0d2ce9f4d4aed6b5f31d3c7e0044a0267f5478d199573980a723fd1a9

Contents?: true

Size: 537 Bytes

Versions: 1

Compression:

Stored size: 537 Bytes

Contents

module VER
  class Text
    class Index < Struct.new(:buffer, :index)
      include Position

      LINE = /^\d+/
      CHAR = /\d+$/

      def line
        index.to_s[LINE].to_i
      end

      def char
        index.to_s[CHAR].to_i
      end

      def to_tcl
        index
      end

      def to_s
        index.to_s
      end

      def to_a
        line, char = index.split('.')
        return line.to_i, char.to_i
      end

      def inspect
        "#<VER::Text::Index %p on %p>" % [index, buffer]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ver-2010.08 lib/ver/text/index.rb