module Hbtrack::Util
This class contains the methods that are used to format the progress of a Habit into string
Constants
- FONT_COLOR
Public Class Methods
convert_key_to_date(key, no_of_space)
click to toggle source
Convert key into date in string form.
@param key [Symbol] The key of the progress in the
form of :'year, month'. Example: :"2017,7"
@param no_of_space [Numeric] number of space to be
added in front
@return [String] a string in date form.
Example¶ ↑
Util.convert_key_to_date(:"2017,7", 0) #=> "July 2016 : "
# File lib/hbtrack/util.rb, line 51 def convert_key_to_date(key, no_of_space) year = key.to_s.split(',')[0] ' ' * no_of_space + get_month_from(key) + " #{year}" + ' : ' end
get_date_from(key:)
click to toggle source
# File lib/hbtrack/util.rb, line 57 def get_date_from(key:) date_component = key.to_s.split(',').map(&:to_i) Date.new(date_component[0], date_component[1], 1) end
get_month_from(key)
click to toggle source
title(string)
click to toggle source