Class: UserAgentParser::Version
- Inherits:
-
Object
- Object
- UserAgentParser::Version
- Defined in:
- lib/user_agent_parser/version.rb
Constant Summary collapse
- SEGMENTS_REGEX =
Private: Regex used to split version string into major, minor, patch, and patch_minor.
/\d+\-\d+|\d+[a-zA-Z]+$|\d+|[A-Za-z][0-9A-Za-z-]*$/
Instance Attribute Summary collapse
-
#version ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
-
#initialize(version) ⇒ Version
constructor
A new instance of Version.
- #inspect ⇒ Object
- #major ⇒ Object
- #minor ⇒ Object
- #patch ⇒ Object
- #patch_minor ⇒ Object
-
#segments ⇒ Object
Private.
Constructor Details
#initialize(version) ⇒ Version
Returns a new instance of Version.
11 12 13 |
# File 'lib/user_agent_parser/version.rb', line 11 def initialize(version) @version = version.to_s.strip end |
Instance Attribute Details
#version ⇒ Object (readonly) Also known as: to_s
Returns the value of attribute version.
8 9 10 |
# File 'lib/user_agent_parser/version.rb', line 8 def version @version end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
35 36 37 38 |
# File 'lib/user_agent_parser/version.rb', line 35 def eql?(other) self.class.eql?(other.class) && version == other.version end |
#inspect ⇒ Object
31 32 33 |
# File 'lib/user_agent_parser/version.rb', line 31 def inspect "#<#{self.class} #{to_s}>" end |
#major ⇒ Object
15 16 17 |
# File 'lib/user_agent_parser/version.rb', line 15 def major segments[0] end |
#minor ⇒ Object
19 20 21 |
# File 'lib/user_agent_parser/version.rb', line 19 def minor segments[1] end |
#patch ⇒ Object
23 24 25 |
# File 'lib/user_agent_parser/version.rb', line 23 def patch segments[2] end |
#patch_minor ⇒ Object
27 28 29 |
# File 'lib/user_agent_parser/version.rb', line 27 def patch_minor segments[3] end |
#segments ⇒ Object
Private
43 44 45 |
# File 'lib/user_agent_parser/version.rb', line 43 def segments @segments ||= version.scan(SEGMENTS_REGEX) end |