Class: Jsapi::Meta::OpenAPI::Version

Inherits:
Object
  • Object
show all
Defined in:
lib/jsapi/meta/openapi/version.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(major, minor) ⇒ Version

Returns a new instance of Version.



24
25
26
27
# File 'lib/jsapi/meta/openapi/version.rb', line 24

def initialize(major, minor)
  @major = major
  @minor = minor
end

Instance Attribute Details

#majorObject (readonly)

Returns the value of attribute major.



22
23
24
# File 'lib/jsapi/meta/openapi/version.rb', line 22

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



22
23
24
# File 'lib/jsapi/meta/openapi/version.rb', line 22

def minor
  @minor
end

Class Method Details

.from(version) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/jsapi/meta/openapi/version.rb', line 7

def self.from(version)
  return version if version.is_a?(Version)

  case version
  when '2.0', 2, nil
    new(2, 0)
  when '3.0', 3
    new(3, 0)
  when '3.1'
    new(3, 1)
  else
    raise ArgumentError, "unsupported OpenAPI version: #{version.inspect}"
  end
end

Instance Method Details

#==(other) ⇒ Object

:nodoc:



29
30
31
32
33
# File 'lib/jsapi/meta/openapi/version.rb', line 29

def ==(other) # :nodoc:
  other.is_a?(self.class) &&
    @major == other.major &&
    @minor == other.minor
end

#to_sObject

:nodoc:



35
36
37
# File 'lib/jsapi/meta/openapi/version.rb', line 35

def to_s # :nodoc:
  "#{major}.#{minor}"
end