Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/hook/hooker.rb

Overview

String helpers

Instance Method Summary collapse

Instance Method Details

#split_hookObject



5
6
7
8
9
10
11
12
# File 'lib/hook/hooker.rb', line 5

def split_hook
  elements = split(/\|\|/)
  {
    name: elements[0],
    url: elements[1],
    path: elements[2]
  }
end

#split_hooksObject



14
15
16
# File 'lib/hook/hooker.rb', line 14

def split_hooks
  split(/\^\^/).map(&:split_hook)
end

#valid_hookObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/hook/hooker.rb', line 18

def valid_hook
  if File.exist?(self)
    File.expand_path(self)
  elsif self =~ /^(hook|http)/
    self
  else
    if self =~ /^\[.*?\]\((.*?)\)$/
      mdlink = $1
      mdlink.valid_hook
    else
      false
    end
  end
end

#valid_hook!Object



33
34
35
# File 'lib/hook/hooker.rb', line 33

def valid_hook!
  replace valid_hook
end