Class: EndOfLife::RubyVersion
- Inherits:
-
Object
- Object
- EndOfLife::RubyVersion
- Includes:
- Comparable
- Defined in:
- lib/end_of_life/ruby_version.rb,
lib/end_of_life/ruby_version/parser.rb
Defined Under Namespace
Modules: Parser
Instance Attribute Summary collapse
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
- .eol_versions_at(date) ⇒ Object
- .from_file(file_name:, content:, parser: Parser) ⇒ Object
- .latest_eol(at: Date.today) ⇒ Object
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #eol?(at: Date.today) ⇒ Boolean
-
#initialize(version_string, eol_date: nil) ⇒ RubyVersion
constructor
A new instance of RubyVersion.
- #to_s ⇒ Object
Constructor Details
#initialize(version_string, eol_date: nil) ⇒ RubyVersion
Returns a new instance of RubyVersion.
46 47 48 49 50 51 |
# File 'lib/end_of_life/ruby_version.rb', line 46 def initialize(version_string, eol_date: nil) @version = Gem::Version.new(version_string) @eol_date = eol_date freeze end |
Instance Attribute Details
#version ⇒ Object (readonly)
Returns the value of attribute version.
44 45 46 |
# File 'lib/end_of_life/ruby_version.rb', line 44 def version @version end |
Class Method Details
.eol_versions_at(date) ⇒ Object
16 17 18 |
# File 'lib/end_of_life/ruby_version.rb', line 16 def eol_versions_at(date) all_versions.filter { |version| version.eol_date <= date } end |
.from_file(file_name:, content:, parser: Parser) ⇒ Object
12 13 14 |
# File 'lib/end_of_life/ruby_version.rb', line 12 def from_file(file_name:, content:, parser: Parser) parser.parse_file(file_name: file_name, content: content) end |
.latest_eol(at: Date.today) ⇒ Object
20 21 22 |
# File 'lib/end_of_life/ruby_version.rb', line 20 def latest_eol(at: Date.today) eol_versions_at(at).max end |
Instance Method Details
#<=>(other) ⇒ Object
57 58 59 |
# File 'lib/end_of_life/ruby_version.rb', line 57 def <=>(other) @version <=> other.version end |
#eol?(at: Date.today) ⇒ Boolean
53 54 55 |
# File 'lib/end_of_life/ruby_version.rb', line 53 def eol?(at: Date.today) self <= RubyVersion.latest_eol(at: at) end |
#to_s ⇒ Object
61 62 63 |
# File 'lib/end_of_life/ruby_version.rb', line 61 def to_s @version.to_s end |