Class: HamlLint::VersionComparer
- Inherits:
-
Object
- Object
- HamlLint::VersionComparer
- Includes:
- Comparable
- Defined in:
- lib/haml_lint/version_comparer.rb
Overview
A simple wrapper around Gem::Version to allow comparison with String instances This makes code shorter in some places
Class Method Summary collapse
- .for_haml ⇒ Object
-
.for_rubocop ⇒ Object
Shortcut to create a version comparer for the current RuboCop’s version.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(version) ⇒ VersionComparer
constructor
A new instance of VersionComparer.
Constructor Details
#initialize(version) ⇒ VersionComparer
Returns a new instance of VersionComparer.
7 8 9 |
# File 'lib/haml_lint/version_comparer.rb', line 7 def initialize(version) @version = Gem::Version.new(version) end |
Class Method Details
.for_haml ⇒ Object
21 22 23 |
# File 'lib/haml_lint/version_comparer.rb', line 21 def self.for_haml new(Haml::VERSION) end |
.for_rubocop ⇒ Object
Shortcut to create a version comparer for the current RuboCop’s version
17 18 19 |
# File 'lib/haml_lint/version_comparer.rb', line 17 def self.for_rubocop new(RuboCop::Version::STRING) end |
Instance Method Details
#<=>(other) ⇒ Object
12 13 14 |
# File 'lib/haml_lint/version_comparer.rb', line 12 def <=>(other) @version <=> Gem::Version.new(other) end |