Class: Crowbar::Client::Util::ApiVersion
- Inherits:
-
Object
- Object
- Crowbar::Client::Util::ApiVersion
- Defined in:
- lib/crowbar/client/util/apiversion.rb
Instance Attribute Summary collapse
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #headers ⇒ Object
-
#initialize(version) ⇒ ApiVersion
constructor
A new instance of ApiVersion.
Constructor Details
#initialize(version) ⇒ ApiVersion
Returns a new instance of ApiVersion.
23 24 25 |
# File 'lib/crowbar/client/util/apiversion.rb', line 23 def initialize(version) @version = version end |
Instance Attribute Details
#version ⇒ Object
Returns the value of attribute version.
21 22 23 |
# File 'lib/crowbar/client/util/apiversion.rb', line 21 def version @version end |
Class Method Details
.default ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/crowbar/client/util/apiversion.rb', line 42 def default os_release_file = "/etc/os-release" if File.exist?(os_release_file) os_release = Hash[ File.open(os_release_file).read.scan(/(\S+)\s*=\s*"([^"]+)/) ] return 1.0 if os_release["VERSION_ID"] == "12.1" && os_release["ID"] == "sles" end 2.0 end |
Instance Method Details
#headers ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/crowbar/client/util/apiversion.rb', line 27 def headers if version == 1.0 { "Accept" => "application/json", "Content-Type" => "application/json" } else { "Accept" => "application/vnd.crowbar.v#{version}+json", "Content-Type" => "application/json" } end end |