Module: InventoryTemplatesHelper

Defined in:
app/helpers/inventory_templates_helper.rb

Overview

typed: true encoding: utf-8 frozen_string_literal: true

Instance Method Summary collapse

Instance Method Details

#get_color(num) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/helpers/inventory_templates_helper.rb', line 37

def get_color(num)
  color = ''
  color = case num
          when 0
            '#d9534f'
          when 1
            '#428bca'
          when 2
            '#5cb85c'
          when 3
            '#f0ad4e'
          when 4
            '#563d7c'
          when 5
            '#5bc0de'
          when 6
            'violet'
          when 7
            '#999'
          else
            'black'
          end
  color
end

#get_intervalsObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/inventory_templates_helper.rb', line 5

def get_intervals
  @intervals = []
  24.times do |h|
    4.times do |m|
      @intervals << if h < 10 && (m != 0)
                      "0#{h}:#{m * 15}"
                    elsif h < 10 && (m == 0)
                      "0#{h}:00"
                    elsif (h >= 10) && (m != 0)
                      "#{h}:#{m * 15}"
                    elsif (h >= 10) && (m == 0)
                      "#{h}:0#{m * 15}"
                    end
    end
  end
  @intervals << '24:00'
end

#int_to_hr(int) ⇒ Object



23
24
25
26
# File 'app/helpers/inventory_templates_helper.rb', line 23

def int_to_hr(int)
  int = "0#{int}" if int < 9
  int.to_s
end

#int_to_min(int) ⇒ Object



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

def int_to_min(int)
  int = if int == 0
          "0#{int}"
        else
          (int * 15).to_s
        end
  int
end