Class: Bridgetown::Drops::UrlDrop

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

Constant Summary

Constants inherited from Drop

Drop::NON_CONTENT_METHODS

Instance Method Summary collapse

Methods inherited from Drop

#[], #[]=, #content_methods, #each, #each_key, #fetch, #hash_for_json, #initialize, #inspect, #key?, #keys, #merge, #merge!, mutable, mutable?, #to_h, #to_json

Constructor Details

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

Instance Method Details

#categoriesObject



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/bridgetown-core/drops/url_drop.rb', line 35

def categories
  category_set = Set.new
  Array(@obj.data["categories"]).each do |category|
    category_set << if @obj.site.config["slugify_categories"]
                      Utils.slugify(category.to_s)
                    else
                      category.to_s.downcase
                    end
  end
  category_set.to_a.join("/")
end

#collectionObject



13
14
15
# File 'lib/bridgetown-core/drops/url_drop.rb', line 13

def collection
  @obj.collection.label
end

#dayObject

DD: 01..31



58
59
60
# File 'lib/bridgetown-core/drops/url_drop.rb', line 58

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

#hourObject

hh: 00..23



63
64
65
# File 'lib/bridgetown-core/drops/url_drop.rb', line 63

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

#i_dayObject

D: 1..31



78
79
80
# File 'lib/bridgetown-core/drops/url_drop.rb', line 78

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

#i_monthObject

M: 1..12



83
84
85
# File 'lib/bridgetown-core/drops/url_drop.rb', line 83

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

#localeObject Also known as: lang



29
30
31
32
# File 'lib/bridgetown-core/drops/url_drop.rb', line 29

def locale
  locale_data = @obj.data["locale"]
  @obj.site.config["available_locales"].include?(locale_data) ? locale_data : nil
end

#long_dayObject

ddd: Monday..Sunday



125
126
127
# File 'lib/bridgetown-core/drops/url_drop.rb', line 125

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

#long_monthObject

MMMM: January..December



93
94
95
# File 'lib/bridgetown-core/drops/url_drop.rb', line 93

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

#minuteObject

mm: 00..59



68
69
70
# File 'lib/bridgetown-core/drops/url_drop.rb', line 68

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

#monthObject

MM: 01..12



53
54
55
# File 'lib/bridgetown-core/drops/url_drop.rb', line 53

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

#nameObject



17
18
19
# File 'lib/bridgetown-core/drops/url_drop.rb', line 17

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

#secondObject

ss: 00..59



73
74
75
# File 'lib/bridgetown-core/drops/url_drop.rb', line 73

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

#short_dayObject

dd: Mon..Sun



120
121
122
# File 'lib/bridgetown-core/drops/url_drop.rb', line 120

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

#short_monthObject

MMM: Jan..Dec



88
89
90
# File 'lib/bridgetown-core/drops/url_drop.rb', line 88

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

#short_yearObject

YY: 00..99



98
99
100
# File 'lib/bridgetown-core/drops/url_drop.rb', line 98

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

#slugObject



25
26
27
# File 'lib/bridgetown-core/drops/url_drop.rb', line 25

def slug
  Utils.slugify(qualified_slug_data)
end

#titleObject



21
22
23
# File 'lib/bridgetown-core/drops/url_drop.rb', line 21

def title
  Utils.slugify(qualified_slug_data, mode: "pretty", cased: true)
end

#w_dayObject

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



115
116
117
# File 'lib/bridgetown-core/drops/url_drop.rb', line 115

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



104
105
106
# File 'lib/bridgetown-core/drops/url_drop.rb', line 104

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

#weekObject

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



110
111
112
# File 'lib/bridgetown-core/drops/url_drop.rb', line 110

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

#y_dayObject

DDD: 001..366



130
131
132
# File 'lib/bridgetown-core/drops/url_drop.rb', line 130

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

#yearObject

CCYY



48
49
50
# File 'lib/bridgetown-core/drops/url_drop.rb', line 48

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