Class: PactBroker::Config::SpaceDelimitedStringList

Inherits:
Array
  • Object
show all
Defined in:
lib/pact_broker/config/space_delimited_string_list.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(list) ⇒ SpaceDelimitedStringList

Returns a new instance of SpaceDelimitedStringList.



5
6
7
# File 'lib/pact_broker/config/space_delimited_string_list.rb', line 5

def initialize list
  super(list)
end

Class Method Details

.parse(string) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/pact_broker/config/space_delimited_string_list.rb', line 9

def self.parse(string)
  array = (string || '').split(' ').collect do | word |
    if word[0] == '/' and word[-1] == '/'
      Regexp.new(word[1..-2])
    else
      word
    end
  end
  SpaceDelimitedStringList.new(array)
end

Instance Method Details

#to_sObject



20
21
22
23
24
25
26
27
28
# File 'lib/pact_broker/config/space_delimited_string_list.rb', line 20

def to_s
  collect do | word |
    if word.is_a?(Regexp)
      "/#{word.source}/"
    else
      word
    end
  end.join(' ')
end