Class: Nexmo::OAS::Renderer::Presenters::Versions
- Inherits:
-
Object
- Object
- Nexmo::OAS::Renderer::Presenters::Versions
- Defined in:
- lib/nexmo/oas/renderer/presenters/versions.rb
Instance Method Summary collapse
- #available_versions ⇒ Object
- #base_name ⇒ Object
- #current_version ⇒ Object
- #definitions ⇒ Object
-
#initialize(definition_name) ⇒ Versions
constructor
A new instance of Versions.
Constructor Details
#initialize(definition_name) ⇒ Versions
Returns a new instance of Versions.
8 9 10 |
# File 'lib/nexmo/oas/renderer/presenters/versions.rb', line 8 def initialize(definition_name) @definition_name = definition_name end |
Instance Method Details
#available_versions ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/nexmo/oas/renderer/presenters/versions.rb', line 23 def available_versions @available_versions ||= begin matches = definitions.select do |definition| definition.match(/^#{base_name}(\.v\d+)?$/) && !definition.include?("#{base_name}/") end matches = matches.map do |definition| m = /\.v(\d+)/.match(definition) next { 'version' => '1', 'name' => definition } unless m { 'version' => m[1], 'name' => definition } end matches.sort_by { |v| v['version'] } end end |
#base_name ⇒ Object
12 13 14 |
# File 'lib/nexmo/oas/renderer/presenters/versions.rb', line 12 def base_name @base_name ||= @definition_name.gsub(/\.v\d+/, '') end |
#current_version ⇒ Object
16 17 18 19 20 21 |
# File 'lib/nexmo/oas/renderer/presenters/versions.rb', line 16 def current_version @current_version ||= begin m = /\.v(\d+)/.match(@definition_name) m.nil? ? '1' : m[1] end end |