Class: Jekyll::Drops::UrlDrop

Inherits:
Drop
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/jekyll/drops/url_drop.rb

Constant Summary

Constants inherited from Drop

Drop::NON_CONTENT_METHODS

Instance Method Summary collapse

Methods inherited from Drop

#[], #[]=, #content_methods, data_delegator, data_delegators, delegate_method, delegate_method_as, delegate_methods, #each, #each_key, #fetch, getter_method_names, #hash_for_json, #initialize, #inspect, #key?, #keys, #merge, #merge!, mutable, mutable?, private_delegate_methods, #to_h, #to_json

Constructor Details

This class inherits a constructor from Jekyll::Drops::Drop

Instance Method Details

#categoriesObject



30
31
32
33
34
35
36
# File 'lib/jekyll/drops/url_drop.rb', line 30

def categories
  category_set = Set.new
  Array(@obj.data["categories"]).each do |category|
    category_set << category.to_s.downcase
  end
  category_set.to_a.join("/")
end

#collectionObject



13
14
15
# File 'lib/jekyll/drops/url_drop.rb', line 13

def collection
  @obj.collection.label
end

#dayObject

DD: 01..31



57
58
59
# File 'lib/jekyll/drops/url_drop.rb', line 57

def day
  @obj.date.strftime("%d")
end

#hourObject

hh: 00..23



62
63
64
# File 'lib/jekyll/drops/url_drop.rb', line 62

def hour
  @obj.date.strftime("%H")
end

#i_dayObject

D: 1..31



77
78
79
# File 'lib/jekyll/drops/url_drop.rb', line 77

def i_day
  @obj.date.strftime("%-d")
end

#i_monthObject

M: 1..12



82
83
84
# File 'lib/jekyll/drops/url_drop.rb', line 82

def i_month
  @obj.date.strftime("%-m")
end

#long_dayObject

ddd: Monday..Sunday



124
125
126
# File 'lib/jekyll/drops/url_drop.rb', line 124

def long_day
  @obj.date.strftime("%A")
end

#long_monthObject

MMMM: January..December



92
93
94
# File 'lib/jekyll/drops/url_drop.rb', line 92

def long_month
  @obj.date.strftime("%B")
end

#minuteObject

mm: 00..59



67
68
69
# File 'lib/jekyll/drops/url_drop.rb', line 67

def minute
  @obj.date.strftime("%M")
end

#monthObject

MM: 01..12



52
53
54
# File 'lib/jekyll/drops/url_drop.rb', line 52

def month
  @obj.date.strftime("%m")
end

#nameObject



17
18
19
# File 'lib/jekyll/drops/url_drop.rb', line 17

def name
  Utils.slugify(@obj.basename_without_ext)
end

#secondObject

ss: 00..59



72
73
74
# File 'lib/jekyll/drops/url_drop.rb', line 72

def second
  @obj.date.strftime("%S")
end

#short_dayObject

dd: Mon..Sun



119
120
121
# File 'lib/jekyll/drops/url_drop.rb', line 119

def short_day
  @obj.date.strftime("%a")
end

#short_monthObject

MMM: Jan..Dec



87
88
89
# File 'lib/jekyll/drops/url_drop.rb', line 87

def short_month
  @obj.date.strftime("%b")
end

#short_yearObject

YY: 00..99



97
98
99
# File 'lib/jekyll/drops/url_drop.rb', line 97

def short_year
  @obj.date.strftime("%y")
end

#slugObject



26
27
28
# File 'lib/jekyll/drops/url_drop.rb', line 26

def slug
  Utils.slugify(@obj.data["slug"]) || Utils.slugify(@obj.basename_without_ext)
end

#slugified_categoriesObject

Similar to output from #categories, but each category will be downcased and all non-alphanumeric characters of the category replaced with a hyphen.



40
41
42
43
44
# File 'lib/jekyll/drops/url_drop.rb', line 40

def slugified_categories
  Array(@obj.data["categories"]).each_with_object(Set.new) do |category, set|
    set << Utils.slugify(category.to_s)
  end.to_a.join("/")
end

#titleObject



21
22
23
24
# File 'lib/jekyll/drops/url_drop.rb', line 21

def title
  Utils.slugify(@obj.data["slug"], :mode => "pretty", :cased => true) ||
    Utils.slugify(@obj.basename_without_ext, :mode => "pretty", :cased => true)
end

#w_dayObject

d: 1..7 (Monday..Sunday)



114
115
116
# File 'lib/jekyll/drops/url_drop.rb', line 114

def w_day
  @obj.date.strftime("%u")
end

#w_yearObject

CCYYw, ISO week year may differ from CCYY for the first days of January and last days of December



103
104
105
# File 'lib/jekyll/drops/url_drop.rb', line 103

def w_year
  @obj.date.strftime("%G")
end

#weekObject

WW: 01..53 %W and %U do not comply with ISO 8601-1



109
110
111
# File 'lib/jekyll/drops/url_drop.rb', line 109

def week
  @obj.date.strftime("%V")
end

#y_dayObject

DDD: 001..366



129
130
131
# File 'lib/jekyll/drops/url_drop.rb', line 129

def y_day
  @obj.date.strftime("%j")
end

#yearObject

CCYY



47
48
49
# File 'lib/jekyll/drops/url_drop.rb', line 47

def year
  @obj.date.strftime("%Y")
end