class UserAgentParser::Version
Constants
- SEGMENTS_REGEX
Private: Regex used to split string version string into major, minor, patch, and patch_minor.
Attributes
to_s[R]
version[R]
Public Class Methods
new(*args)
click to toggle source
# File lib/user_agent_parser/version.rb, line 12 def initialize(*args) # If only one string argument is given, assume a complete version string # and attempt to parse it if args.length == 1 && args.first.is_a?(String) @version = args.first.to_s.strip else @segments = args.compact.map(&:to_s).map(&:strip) @version = segments.join('.') end end
Public Instance Methods
eql?(other)
click to toggle source
# File lib/user_agent_parser/version.rb, line 43 def eql?(other) self.class.eql?(other.class) && version == other.version end
Also aliased as: ==
inspect()
click to toggle source
# File lib/user_agent_parser/version.rb, line 39 def inspect "#<#{self.class} #{self}>" end
major()
click to toggle source
# File lib/user_agent_parser/version.rb, line 23 def major segments[0] end
minor()
click to toggle source
# File lib/user_agent_parser/version.rb, line 27 def minor segments[1] end
patch()
click to toggle source
# File lib/user_agent_parser/version.rb, line 31 def patch segments[2] end
patch_minor()
click to toggle source
# File lib/user_agent_parser/version.rb, line 35 def patch_minor segments[3] end
segments()
click to toggle source
Private
# File lib/user_agent_parser/version.rb, line 51 def segments @segments ||= version.scan(SEGMENTS_REGEX) end
to_h()
click to toggle source
# File lib/user_agent_parser/version.rb, line 55 def to_h { version: version, major: major, minor: minor, patch: patch, patch_minor: patch_minor } end