Module: Clearbit::Slack::Helpers
- Included in:
- Attachments::Company, Attachments::Person
- Defined in:
- lib/clearbit/slack/helpers.rb
Instance Method Summary collapse
- #aboutme(aboutme) ⇒ Object
- #angellist(angellist) ⇒ Object
- #facebook(facebook) ⇒ Object
- #field(title, value, short = true) ⇒ Object
- #format_number(value) ⇒ Object
- #github(github) ⇒ Object
- #link(url, title, followers = nil) ⇒ Object
- #linkedin(linkedin) ⇒ Object
- #twitter(twitter) ⇒ Object
Instance Method Details
#aboutme(aboutme) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/clearbit/slack/helpers.rb', line 25 def aboutme(aboutme) return unless aboutme && aboutme.handle value = link( "https://about.me/#{aboutme.handle}", aboutme.handle ) field 'AboutMe', value end |
#angellist(angellist) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/clearbit/slack/helpers.rb', line 34 def angellist(angellist) return unless angellist && angellist.handle value = link( "https://angel.co/#{angellist.handle}", angellist.handle, angellist.followers ) field 'AngelList', value end |
#facebook(facebook) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/clearbit/slack/helpers.rb', line 54 def facebook(facebook) return unless facebook && facebook.handle value = link( "https://www.facebook.com/#{facebook.handle}", facebook.handle ) field 'Facebook', value end |
#field(title, value, short = true) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/clearbit/slack/helpers.rb', line 8 def field(title, value, short = true) { title: title, value: value, short: short } end |
#format_number(value) ⇒ Object
4 5 6 |
# File 'lib/clearbit/slack/helpers.rb', line 4 def format_number(value) value.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse end |
#github(github) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/clearbit/slack/helpers.rb', line 44 def github(github) return unless github && github.handle value = link( "https://github.com/#{github.handle}", github.handle, github.followers ) field 'GitHub', value end |
#link(url, title, followers = nil) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/clearbit/slack/helpers.rb', line 16 def link(url, title, followers = nil) if followers followers = format_number(followers) followers = " (#{followers} followers)" end "<#{url}|#{title}>#{followers}".strip end |
#linkedin(linkedin) ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/clearbit/slack/helpers.rb', line 73 def linkedin(linkedin) return unless linkedin && linkedin.handle value = link( "https://www.linkedin.com/#{linkedin.handle}", linkedin.handle ) field 'LinkedIn', value end |
#twitter(twitter) ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/clearbit/slack/helpers.rb', line 63 def twitter(twitter) return unless twitter && twitter.handle value = link( "http://twitter.com/#{twitter.handle}", twitter.handle, twitter.followers ) field 'Twitter', value end |