Class: Gitlab::Headers::Total

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/headers/total.rb

Constant Summary collapse

HEADER_TOTAL =
'x-total'
TOTAL_REGEX =
/^\d+$/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(headers) ⇒ Total

Returns a new instance of Total.



11
12
13
14
15
# File 'lib/gitlab/headers/total.rb', line 11

def initialize(headers)
  header_total = headers[HEADER_TOTAL]

  extract_total(header_total) if header_total
end

Instance Attribute Details

#total ⇒ Object

Returns the value of attribute total.



9
10
11
# File 'lib/gitlab/headers/total.rb', line 9

def total
  @total
end

Instance Method Details

#extract_total(header_total) ⇒ Object



17
18
19
20
21
# File 'lib/gitlab/headers/total.rb', line 17

def extract_total(header_total)
  TOTAL_REGEX.match(header_total.strip) do |match|
    @total = match[0]
  end
end