Class: Jekyll::HackclubPFP
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jekyll::HackclubPFP
- Defined in:
- lib/tags/profile-pic.rb
Instance Method Summary collapse
-
#initialize(tagName, content, tokens) ⇒ HackclubPFP
constructor
A new instance of HackclubPFP.
- #render(context) ⇒ Object
Constructor Details
#initialize(tagName, content, tokens) ⇒ HackclubPFP
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/tags/profile-pic.rb', line 6 def initialize(tagName, content, tokens) super if content.strip =~ /^(U\w+)(?:@(.+))?$/ id = Regexp.last_match(1) data = HackclubRequest.raw_user(id) @resolution = Regexp.last_match(2) || "original" @img_url = data.dig("user", "profile", "image_"+@resolution) @name = data.dig("user", "name") else raise ArgumentError, "Invalid profilepic tag format: #{content}" end end |
Instance Method Details
#render(context) ⇒ Object
20 21 22 |
# File 'lib/tags/profile-pic.rb', line 20 def render(context) %Q{<img src="#{@img_url}" title="#{@name}'s profile picture" alt="#{@name}'s profile picture" class="hackclub-pfp res-#{@resolution}">} end |