Class: IdsPlease::Parsers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ids_please/parsers/base.rb

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


18
19
20
# File 'lib/ids_please/parsers/base.rb', line 18

def parse_link(link)
  link.path.split('/')[1]
end

.to_symObject



6
7
8
# File 'lib/ids_please/parsers/base.rb', line 6

def to_sym
  name.split('::').last.downcase.to_sym
end

.valid_id_regexObject



22
23
24
# File 'lib/ids_please/parsers/base.rb', line 22

def valid_id_regex
  /\A([\w\.\+-]{2,})/
end