Sha256: 5b378cde6d3530adf34312ff306d15d2e29e297b2c0346970ae77098accd6bb9

Contents?: true

Size: 356 Bytes

Versions: 12

Compression:

Stored size: 356 Bytes

Contents

module Lookbook
  class PositionPrefixParser < Service
    POSITION_PREFIX_REGEX = /^(\d+?)[-_]/

    attr_reader :input

    def initialize(input)
      @input = String(input)
    end

    def call
      matches = input.match(POSITION_PREFIX_REGEX)
      matches ? [matches[1].to_i, input.gsub(POSITION_PREFIX_REGEX, "")] : [nil, input]
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
lookbook-1.5.5 lib/lookbook/services/position_prefix_parser.rb
lookbook-1.5.4 lib/lookbook/services/position_prefix_parser.rb
lookbook-1.5.3 lib/lookbook/services/position_prefix_parser.rb
lookbook-1.5.2 lib/lookbook/services/position_prefix_parser.rb
lookbook-1.5.1 lib/lookbook/services/position_prefix_parser.rb
lookbook-1.5.0 lib/lookbook/services/position_prefix_parser.rb
lookbook-1.4.5 lib/lookbook/services/position_prefix_parser.rb
lookbook-1.4.4 lib/lookbook/services/position_prefix_parser.rb
lookbook-1.4.3 lib/lookbook/services/position_prefix_parser.rb
lookbook-1.4.2 lib/lookbook/services/position_prefix_parser.rb
lookbook-1.4.1 lib/lookbook/services/position_prefix_parser.rb
lookbook-1.4.0 lib/lookbook/services/position_prefix_parser.rb