Module: FeaturesHelper

Defined in:
lib/gutkumber/features_helper.rb

Constant Summary collapse

STRING_RE =
/"((?:[^"]|\\")+)"/
NUMBER_RE =
/(\d+|zero|one|two|three|four|five|six|seven|eight|nine|ten)/
ORDINALS =
{
  "first" => 1,
  "second" => 2,
  "third" => 3,
  "fourth" => 4,
  "fifth" => 5,
  "sixth" => 6,
  "seventh" => 7,
  "eighth" => 8,
  "ninth" => 9,
  "tenth" => 10
}
ORDINAL_RE =
/(#{ORDINALS.keys.join("|")})/

Instance Method Summary collapse

Instance Method Details

#only(array) ⇒ Object



32
33
34
35
# File 'lib/gutkumber/features_helper.rb', line 32

def only(array)
  array.length.should == 1
  array.first
end

#parse_number(number) ⇒ Object



19
20
21
22
# File 'lib/gutkumber/features_helper.rb', line 19

def parse_number(number)
  numbers = %w(zero one two three four five six seven eight nine ten)
  numbers.index(number) || number.to_i
end

#parse_ordinal(ordinal) ⇒ Object



28
29
30
# File 'lib/gutkumber/features_helper.rb', line 28

def parse_ordinal(ordinal)
  ORDINALS[ordinal]
end

#parse_string(string) ⇒ Object



24
25
26
# File 'lib/gutkumber/features_helper.rb', line 24

def parse_string(string)
  string.gsub("\\\"", "\"")
end