Module: OrganizationsHelper

Defined in:
app/helpers/organizations_helper.rb

Instance Method Summary collapse

Instance Method Details

#progress_bar_attributes(local_vars) ⇒ Hash

Returns aria and style attributes for drawing a progress bar

Parameters:

  • local_vars (Hash)

    passed to the partial as “local assigns”; lets our templates optionally specify certain parameters

Returns:

  • (Hash)

    aria and style attributes for drawing a progress bar

See Also:



17
18
19
20
21
22
23
# File 'app/helpers/organizations_helper.rb', line 17

def progress_bar_attributes(local_vars)
  { :"aria-valuemax" => progress_max(local_vars),
    :"aria-valuemin" => progress_min(local_vars),
    :"aria-valuenow" => progress_val(local_vars),
    :role => "progressbar",
    :style => "width: #{progress_bar_percentage(local_vars)}%" }
end

#progress_bar_percentage(local_vars) ⇒ String

Returns formatted progress percentage of value vs max

Parameters:

  • local_vars (Hash)

    passed to the partial as “local assigns”; lets our templates optionally specify certain parameters

Returns:

  • (String)

    formatted progress percentage of value vs max



27
28
29
30
31
32
33
34
# File 'app/helpers/organizations_helper.rb', line 27

def progress_bar_percentage(local_vars)
  max = progress_max(local_vars)
  return "" if max.zero?

  value = progress_val(local_vars)
  percentage = 100 * (value / max.to_f)
  number_to_percentage(percentage, precision: 0)
end

#progress_label(title, value) ⇒ Object

Parameters:

  • title (String)

    string to use for the label

  • value (Integer)

    numerical value for the label



38
39
40
# File 'app/helpers/organizations_helper.rb', line 38

def progress_label(title, value)
  "#{number_with_delimiter(value)} #{title}"
end

#representation_count(count) ⇒ String

Returns formatted number of representations, with correct pluralization

Parameters:

  • count (Integer)

Returns:

  • (String)

    formatted number of representations, with correct pluralization



10
11
12
# File 'app/helpers/organizations_helper.rb', line 10

def representation_count(count)
  "#{number_with_delimiter(count)} #{'representation'.pluralize(count)}"
end

#resource_count(count) ⇒ String

Returns formatted number of images, with correct pluralization

Parameters:

  • count (Integer)

Returns:

  • (String)

    formatted number of images, with correct pluralization



4
5
6
# File 'app/helpers/organizations_helper.rb', line 4

def resource_count(count)
  "#{number_with_delimiter(count)} #{'resource'.pluralize(count)}"
end