Class: Lookbook::PriorityPrefixParser

Inherits:
Service
  • Object
show all
Defined in:
lib/lookbook/services/priority_prefix_parser.rb

Constant Summary collapse

PRIORITY_PREFIX_REGEX =
/^(\d+?)[-_]/

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Service

call

Constructor Details

#initialize(input) ⇒ PriorityPrefixParser

Returns a new instance of PriorityPrefixParser.



7
8
9
# File 'lib/lookbook/services/priority_prefix_parser.rb', line 7

def initialize(input)
  @input = String(input)
end

Instance Attribute Details

#inputObject (readonly)



5
6
7
# File 'lib/lookbook/services/priority_prefix_parser.rb', line 5

def input
  @input
end

Instance Method Details

#callObject



11
12
13
14
# File 'lib/lookbook/services/priority_prefix_parser.rb', line 11

def call
  matches = input.match(PRIORITY_PREFIX_REGEX)
  matches ? [matches[1].to_i, input.gsub(PRIORITY_PREFIX_REGEX, "")] : [nil, input]
end