Class: Evertils::Helper::Formatting

Inherits:
Object
  • Object
show all
Defined in:
lib/evertils/helpers/formatting.rb

Class Method Summary collapse

Class Method Details

.clean(text) ⇒ Object

Since:

  • 2.2.0



39
40
41
# File 'lib/evertils/helpers/formatting.rb', line 39

def self.clean(text)
  text.delete("\n").gsub(' ', ' ')
end

.current_timeObject

Since:

  • 2.2.1



45
46
47
# File 'lib/evertils/helpers/formatting.rb', line 45

def self.current_time
  Time.now.strftime('%I:%M')
end

.date_templatesObject

Template string for note title



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/evertils/helpers/formatting.rb', line 7

def self.date_templates
  current_date = Date.today
  week_stub = current_date.strftime('%a')
  start_of_week = Date.commercial(current_date.year, current_date.cweek, 1)
  end_of_week = Date.commercial(current_date.year, current_date.cweek, 5)

  {
    :Daily => "Daily Log [#{current_date.strftime('%B %-d')} - #{week_stub}]",
    :Weekly => "Weekly Log [#{start_of_week.strftime('%B %-d')} - #{end_of_week.strftime('%B %-d')}]",
    :Monthly => "Monthly Log [#{current_date.strftime('%B %Y')}]",
    :Deployments => "#{current_date.strftime('%B %-d')} - #{week_stub}",
    :'Priority Queue' => "Queue For [#{current_date.strftime('%B %-d')} - #{week_stub}]"
  }
end

.symbolize_keys(hash) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/evertils/helpers/formatting.rb', line 22

def self.symbolize_keys(hash)
  hash.inject({}){ |result, (key, value)|
    new_key = case key
              when String then key.to_sym
              else key
              end
    new_value = case value
                when Hash then symbolize_keys(value)
                else value
                end
    result[new_key] = new_value
    result
  }
end