Sha256: 66d314e1ea259d3a6cc47a9b68517ac5849f8a734e3dce4d941bbf052d420f53

Contents?: true

Size: 511 Bytes

Versions: 3

Compression:

Stored size: 511 Bytes

Contents

module UserAgentParser
  
  class Version

    attr_accessor :version
    alias :to_s :version

    def initialize(version)
      self.version = version.to_s.strip
    end

    def segments
      version.scan(/\d+\-\d+|\d+[a-zA-Z]+$|\d+|[A-Za-z][0-9A-Za-z-]*$/).map do |s|
        /^\d+$/ =~ s ? s.to_i : s
      end
    end

    def [](segment)
      segments[segment]
    end
  
    def inspect
      "#<#{self.class} #{to_s}>"
    end
    
    def ==(other)
      version == other.version
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
user_agent_parser-0.1.2 lib/user_agent_parser/version.rb
user_agent_parser-0.1.1 lib/user_agent_parser/version.rb
user_agent_parser-0.1.0 lib/user_agent_parser/version.rb