Module: Jekyll::TermFormat
- Defined in:
- jekyll/_plugins/term-format.rb
Instance Method Summary collapse
- #term2dateString(input) ⇒ Object
- #termCodeAsMonths(input) ⇒ Object
- #termformat(input) ⇒ Object
- #termKeyAsMonths(input) ⇒ Object
- #termkeyformat(input) ⇒ Object
- #termMonth(input) ⇒ Object
- #termName(input) ⇒ Object
- #termNameAsMonth(input) ⇒ Object
- #termNameOnlyFromTermKey(input) ⇒ Object
- #termYear(input) ⇒ Object
- #termYearOnlyFromTermKey(input) ⇒ Object
Instance Method Details
#term2dateString(input) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'jekyll/_plugins/term-format.rb', line 142 def term2dateString(input) if (input.nil?) return nil end year = termYear(input) month = termMonth(input) if month == 9 month = month - 1 elsif month == 6 month = month - 1 end "#{"%d/1/%d" % [month, year]}" end |
#termCodeAsMonths(input) ⇒ Object
172 173 174 175 176 177 178 179 180 |
# File 'jekyll/_plugins/term-format.rb', line 172 def termCodeAsMonths(input) if (input.nil?) return nil end term_year = termYear(input) term_month = termMonth(input) months = term_year * 12 + term_month; "#{"%d" % [months]}" end |
#termformat(input) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'jekyll/_plugins/term-format.rb', line 37 def termformat(input) if (input == nil) return "BAD TERM" end values = input.split("/") year = values[0].to_i month = values[1].to_i if month == 1 term_string = "Spring" elsif month == 6 term_string = "Summer" elsif month == 9 term_string = "Fall" end "#{"%s %d" % [term_string, year]}" end |
#termKeyAsMonths(input) ⇒ Object
183 184 185 186 187 188 189 190 191 192 |
# File 'jekyll/_plugins/term-format.rb', line 183 def termKeyAsMonths(input) if (input.nil?) return nil end term_year = termYearOnlyFromTermKey(input) term_name = termNameOnlyFromTermKey(input) term_month = termNameAsMonth(term_name) months = term_year * 12 + term_month; "#{"%d" % [months]}" end |
#termkeyformat(input) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'jekyll/_plugins/term-format.rb', line 53 def termkeyformat(input) if (input.nil?) return nil end values = input.split("_") year = values[0].to_i month = values[1] if month == "spring" term_string = "Spring" elsif month == "summer" term_string = "Summer" elsif month == "fall" term_string = "Fall" end "#{"%s %d" % [term_string, year]}" end |
#termMonth(input) ⇒ Object
134 135 136 137 138 139 140 |
# File 'jekyll/_plugins/term-format.rb', line 134 def termMonth(input) if (input.nil?) return nil end values = input.split("/") month = values[1].to_i end |
#termName(input) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'jekyll/_plugins/term-format.rb', line 70 def termName(input) # "2016/1" -> "spring" if (input.nil?) return nil end values = input.split("/") year = values[0].to_i month = values[1].to_i if month == 1 term_string = "spring" elsif month == 6 term_string = "summer" elsif month == 9 term_string = "fall" end "#{"%s" % [term_string]}" end |
#termNameAsMonth(input) ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'jekyll/_plugins/term-format.rb', line 158 def termNameAsMonth(input) if (input.nil?) return nil end if (input == "Spring") term_month = 1 elsif (input == "Summer") term_month = 6 else term_month = 9 end "#{"%d" % [term_month]}" end |
#termNameOnlyFromTermKey(input) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'jekyll/_plugins/term-format.rb', line 89 def termNameOnlyFromTermKey(input) # "2016_spring" -> "Spring" if (input.nil?) return nil end values = input.split("_") year = values[0].to_i month = values[1] if month == "spring" term_string = "Spring" elsif month == "summer" term_string = "Summer" elsif month == "fall" term_string = "Fall" end "#{"%s" % [term_string]}" end |
#termYear(input) ⇒ Object
126 127 128 129 130 131 132 |
# File 'jekyll/_plugins/term-format.rb', line 126 def termYear(input) if (input.nil?) return nil end values = input.split("/") year = values[0].to_i end |
#termYearOnlyFromTermKey(input) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'jekyll/_plugins/term-format.rb', line 107 def termYearOnlyFromTermKey(input) # "2016_spring" -> "2016" if (input.nil?) return nil end values = input.split("_") year = values[0].to_i month = values[1] if month == "spring" term_string = "Spring" elsif month == "summer" term_string = "Summer" elsif month == "fall" term_string = "Fall" end "#{"%d" % [year]}" end |