Class: RallyAPI::CustomHttpHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/rally_api/custom_http_header.rb

Constant Summary collapse

HTTP_HEADER_FIELDS =
[:name, :vendor, :version, :library, :platform, :os]
HTTP_HEADER_PREFIX =
'X-RallyIntegration'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(custom_vals = {}) ⇒ CustomHttpHeader

Returns a new instance of CustomHttpHeader.



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rally_api/custom_http_header.rb', line 19

def initialize(custom_vals = {})
  @os = RUBY_PLATFORM
  @platform = "Ruby #{RUBY_VERSION}"
  @library = "RallyRestJson version #{RallyAPI::VERSION}"
  @name = "RallyRestJsonRuby"

  if custom_vals.keys.length > 0
    @name    = custom_vals[:name]     unless custom_vals[:name].nil?
    @version = custom_vals[:version]
    @vendor  = custom_vals[:vendor]
  end
end

Instance Attribute Details

#libraryObject (readonly)

Returns the value of attribute library.



14
15
16
# File 'lib/rally_api/custom_http_header.rb', line 14

def library
  @library
end

#nameObject

Returns the value of attribute name.



13
14
15
# File 'lib/rally_api/custom_http_header.rb', line 13

def name
  @name
end

#osObject (readonly)

Returns the value of attribute os.



14
15
16
# File 'lib/rally_api/custom_http_header.rb', line 14

def os
  @os
end

#platformObject (readonly)

Returns the value of attribute platform.



14
15
16
# File 'lib/rally_api/custom_http_header.rb', line 14

def platform
  @platform
end

#vendorObject

Returns the value of attribute vendor.



13
14
15
# File 'lib/rally_api/custom_http_header.rb', line 13

def vendor
  @vendor
end

#versionObject

Returns the value of attribute version.



13
14
15
# File 'lib/rally_api/custom_http_header.rb', line 13

def version
  @version
end

Instance Method Details

#headersObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/rally_api/custom_http_header.rb', line 32

def headers
  headers = {}
  HTTP_HEADER_FIELDS.each do |field|
    value = self.send(field)
    next if value.nil?
    header_key = "#{HTTP_HEADER_PREFIX}#{field.to_s.capitalize}"
    headers[header_key.to_sym] = value
  end
  headers
end