Class: Chespirito::RouteUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/chespirito/routes/route_utils.rb

Class Method Summary collapse

Class Method Details

.constraint?(word) ⇒ Boolean

Returns:

  • (Boolean)


10
# File 'lib/chespirito/routes/route_utils.rb', line 10

def constraint?(word)  = word.start_with?(":")

.constraints(path) ⇒ Object



7
# File 'lib/chespirito/routes/route_utils.rb', line 7

def constraints(path)  = words(path).select(&method(:constraint?)).map(&method(:remove_colon))

.part?(word) ⇒ Boolean

Returns:

  • (Boolean)


9
# File 'lib/chespirito/routes/route_utils.rb', line 9

def part?(word)        = !constraint?(word)

.parts(path) ⇒ Object



8
# File 'lib/chespirito/routes/route_utils.rb', line 8

def parts(path)        = words(path).select(&method(:part?))

.remove_colon(word) ⇒ Object



11
# File 'lib/chespirito/routes/route_utils.rb', line 11

def remove_colon(word) = word.gsub(":", '')

.words(path) ⇒ Object



6
# File 'lib/chespirito/routes/route_utils.rb', line 6

def words(path)        = path.split("/").delete_if(&:empty?)