Module: TF2R::TextHelpers
Overview
This module provides common methods for manipulating text throughout this gem. Common operations include messing with Steam ID 64s, hex color codes, and link to resources on TF2R.
Instance Method Summary collapse
-
#extract_colour(str) ⇒ String
Extracts a hex colour code.
-
#extract_link_snippet(text) ⇒ String
Extract the link_snippet from a path or link.
-
#extract_steam_id(href) ⇒ Fixnum
Extracts a SteamID64 from a TF2R user link.
-
#raffle_link(link_snippet) ⇒ String
Generates the TF2R link for a raffle given a link snippet.
- #raffle_link_full(link_snippet) ⇒ Object
Instance Method Details
#extract_colour(str) ⇒ String
Extracts a hex colour code.
13 14 15 |
# File 'lib/tf2r/text_helpers.rb', line 13 def extract_colour(str) /#(\w+)\s*;/.match(str)[1].downcase end |
#extract_link_snippet(text) ⇒ String
Extract the link_snippet from a path or link.
21 22 23 |
# File 'lib/tf2r/text_helpers.rb', line 21 def extract_link_snippet(text) /\/(k.+)\.html/.match(text)[1] end |
#extract_steam_id(href) ⇒ Fixnum
Extracts a SteamID64 from a TF2R user link.
33 34 35 |
# File 'lib/tf2r/text_helpers.rb', line 33 def extract_steam_id(href) /http:\/\/tf2r.com\/user\/(\d+)\.html/.match(href)[1].to_i end |
#raffle_link(link_snippet) ⇒ String
Generates the TF2R link for a raffle given a link snippet.
44 45 46 |
# File 'lib/tf2r/text_helpers.rb', line 44 def raffle_link(link_snippet) link = "http://tf2r.com/#{link_snippet}.html" end |
#raffle_link_full(link_snippet) ⇒ Object
52 53 54 |
# File 'lib/tf2r/text_helpers.rb', line 52 def raffle_link_full(link_snippet) "#{raffle_link(link_snippet)}?full" end |