Sha256: 33054b23f14864050428467703185e7d269f5fe935818119a353e9db1f7eb72d

Contents?: true

Size: 666 Bytes

Versions: 17

Compression:

Stored size: 666 Bytes

Contents

module LessonsIndexer
  module Models
    class Base
      include Comparable

      VERSION_PATTERN = /(?<minor_major>(?<major>(\d+))(?:\.|-)(?<minor>(\d+)))/i
      attr_reader :file_name, :major, :minor, :path

      def initialize(file_name)
        @file_name = file_name
        @path = File.expand_path(file_name)
        @major = file_name.match(VERSION_PATTERN)[:major].to_i
        @minor = file_name.match(VERSION_PATTERN)[:minor].to_i
      end

      def <=>(other)
        if self.major == other.major
          self.minor <=> other.minor
        else
          self.major <=> other.major
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
lessons_indexer-1.3.0 lib/lessons_indexer/models/base.rb
lessons_indexer-1.2.2 lib/lessons_indexer/models/base.rb
lessons_indexer-1.2.1 lib/lessons_indexer/models/base.rb
lessons_indexer-1.2.0 lib/lessons_indexer/models/base.rb
lessons_indexer-1.1.0 lib/lessons_indexer/models/base.rb
lessons_indexer-1.0.3 lib/lessons_indexer/models/base.rb
lessons_indexer-1.0.2.1 lib/lessons_indexer/models/base.rb
lessons_indexer-1.0.0 lib/lessons_indexer/models/base.rb
lessons_indexer-0.3.1 lib/lessons_indexer/models/base.rb
lessons_indexer-0.3.0 lib/lessons_indexer/models/base.rb
lessons_indexer-0.2.3 lib/lessons_indexer/models/base.rb
lessons_indexer-0.2.2 lib/lessons_indexer/models/base.rb
lessons_indexer-0.2.1 lib/lessons_indexer/models/base.rb
lessons_indexer-0.2.0 lib/lessons_indexer/models/base.rb
lessons_indexer-0.1.2 lib/lessons_indexer/models/base.rb
lessons_indexer-0.1.1 lib/lessons_indexer/models/base.rb
lessons_indexer-0.1.0 lib/lessons_indexer/models/base.rb