Sha256: f43e212ccc00e6b33eafe70997dee51a3425db47d5ca10a5444eeaf08b806102

Contents?: true

Size: 962 Bytes

Versions: 2

Compression:

Stored size: 962 Bytes

Contents

module Aeternitas
  module WebUi
    module ApplicationHelper
      def rate_ratio(ratio)
        label_type = case ratio
                       when 0.0...0.01
                         "badge badge-success"
                       when 0.01...0.1
                         "badge badge-warning"
                       else
                         "badge badge-danger"
                     end

        content_tag :span, "#{ratio * 100}%", class: label_type
      end

      def get_identifier(pollable)
        identifier = pollable.id.to_s
        identifier +=
          if pollable.respond_to?(:name)
            ' - ' + pollable.name.to_s
          elsif pollable.respond_to? :label
            ' - ' + pollable.label.to_s
          elsif pollable.respond_to? :identifier
            ' - ' + pollable.identifier.to_s
          elsif pollable.respond_to? :url
            ' - ' + pollable.url.to_s
        end

        identifier
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aeternitas_web_ui-0.2.1 app/helpers/aeternitas/web_ui/application_helper.rb
aeternitas_web_ui-0.2.0 app/helpers/aeternitas/web_ui/application_helper.rb