Class: Wikimovia::Formatters::TimeFormatter

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/wikimovia/formatters/time_formatter.rb

Constant Summary collapse

MINUTES_PATTERN =
/^(\d+) minutes$/

Instance Method Summary collapse

Methods included from Utilities

#extract_pattern, template_regex

Instance Method Details

#format(string) ⇒ Object

If the string matches the pattern of ‘NUMBER minutes’, returns NUMBER. otherwise returns the string.



10
11
12
13
14
15
16
# File 'lib/wikimovia/formatters/time_formatter.rb', line 10

def format(string)
  case string
  when MINUTES_PATTERN
    extract_pattern(MINUTES_PATTERN, string).to_i * 60
  else string
  end
end