Class: IdsPlease::Parsers::Base
- Inherits:
-
Object
- Object
- IdsPlease::Parsers::Base
show all
- Defined in:
- lib/ids_please/parsers/base.rb
Direct Known Subclasses
Ameba, Blogger, Facebook, GooglePlus, Hi5, Instagram, Linkedin, Livejournal, Mailru, Moikrug, Odnoklassniki, Pinterest, Reddit, Soundcloud, Tumblr, Twitter, Vimeo, Vkontakte, Youtube
Class Method Summary
collapse
Class Method Details
.interact(links) ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/ids_please/parsers/base.rb', line 10
def interact(links)
links.map do |l|
id = parse_link(l)
matched_id = id.match(valid_id_regex) if id
matched_id[1] if matched_id
end.compact
end
|
.parse_link(link) ⇒ Object
18
19
20
|
# File 'lib/ids_please/parsers/base.rb', line 18
def parse_link(link)
link.path.split('/')[1]
end
|
.to_sym ⇒ Object
6
7
8
|
# File 'lib/ids_please/parsers/base.rb', line 6
def to_sym
name.split('::').last.downcase.to_sym
end
|
.valid_id_regex ⇒ Object
22
23
24
|
# File 'lib/ids_please/parsers/base.rb', line 22
def valid_id_regex
/\A([\w\.\+-]{2,})/
end
|