Module: CukeSalad::Specifics

Defined in:
lib/cukesalad/specifics.rb

Instance Method Summary collapse

Instance Method Details

#names_and_values_in(details) ⇒ Object



23
24
25
26
# File 'lib/cukesalad/specifics.rb', line 23

def names_and_values_in details
  specifics_pattern = /('[^']+'|"[^"]+")/
  details.split(specifics_pattern)
end

#set_last(value) ⇒ Object



19
20
21
# File 'lib/cukesalad/specifics.rb', line 19

def set_last value
  @info[@info.keys.last] = value
end

#symbolized(name) ⇒ Object



28
29
30
# File 'lib/cukesalad/specifics.rb', line 28

def symbolized name
  name.strip.gsub(' ', '_').to_sym
end

#the_value_from_the(item) ⇒ Object



32
33
34
# File 'lib/cukesalad/specifics.rb', line 32

def the_value_from_the item 
  item.gsub(/((?:^'|'$)|(?:^"|"$))/, '') unless item.nil?
end

#understand_the(details) ⇒ Object



3
4
5
# File 'lib/cukesalad/specifics.rb', line 3

def understand_the details
  @info = with_specifics_from( details )
end

#value_of(symbol) ⇒ Object



7
8
9
# File 'lib/cukesalad/specifics.rb', line 7

def value_of(symbol)
  @info[symbol]
end

#with_specifics_from(details) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/cukesalad/specifics.rb', line 11

def with_specifics_from details
  result = {}
  names_and_values_in(details).each_slice(2) do |name_value| 
    result[symbolized name_value[0]] = the_value_from_the name_value[1]
  end
  result
end