Class: LessonsIndexer::Models::Base
- Inherits:
-
Object
- Object
- LessonsIndexer::Models::Base
- Includes:
- Comparable
- Defined in:
- lib/lessons_indexer/models/base.rb
Constant Summary collapse
- VERSION_PATTERN =
/(?<minor_major>(?<major>(\d+))(?:\.|-)(?<minor>(\d+)))/i
Instance Attribute Summary collapse
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#major ⇒ Object
readonly
Returns the value of attribute major.
-
#minor ⇒ Object
readonly
Returns the value of attribute minor.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(file_name) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(file_name) ⇒ Base
Returns a new instance of Base.
9 10 11 12 13 14 |
# File 'lib/lessons_indexer/models/base.rb', line 9 def initialize(file_name) @file_name = file_name @path = File.(file_name) @major = file_name.match(VERSION_PATTERN)[:major].to_i @minor = file_name.match(VERSION_PATTERN)[:minor].to_i end |
Instance Attribute Details
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
7 8 9 |
# File 'lib/lessons_indexer/models/base.rb', line 7 def file_name @file_name end |
#major ⇒ Object (readonly)
Returns the value of attribute major.
7 8 9 |
# File 'lib/lessons_indexer/models/base.rb', line 7 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
7 8 9 |
# File 'lib/lessons_indexer/models/base.rb', line 7 def minor @minor end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/lessons_indexer/models/base.rb', line 7 def path @path end |
Instance Method Details
#<=>(other) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/lessons_indexer/models/base.rb', line 16 def <=>(other) if self.major == other.major self.minor <=> other.minor else self.major <=> other.major end end |