Class: Pubid::Core::Edition

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/pubid/core/edition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config:, year: nil, number: nil) ⇒ Edition

Returns a new instance of Edition.



6
7
8
9
10
# File 'lib/pubid/core/edition.rb', line 6

def initialize(config:, year: nil, number: nil)
  @config = config
  @year = year
  @number = number
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



4
5
6
# File 'lib/pubid/core/edition.rb', line 4

def config
  @config
end

#numberObject

Returns the value of attribute number.



4
5
6
# File 'lib/pubid/core/edition.rb', line 4

def number
  @number
end

#yearObject

Returns the value of attribute year.



4
5
6
# File 'lib/pubid/core/edition.rb', line 4

def year
  @year
end

Instance Method Details

#<=>(other) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/pubid/core/edition.rb', line 12

def <=>(other)
  if other.year && year
    return number <=> other.number if year == other.year

    year <=> other.year
  else
    number <=> other.number
  end
end