Module: SmartTime

Extended by:
ActiveSupport::Autoload
Defined in:
lib/smart_time.rb,
lib/smart_time/parser/smart_parser.rb,
lib/smart_time/active_record_extension.rb,
lib/smart_time/parser/ruby_date_parser.rb,
lib/smart_time/parser/ruby_time_parser.rb,
lib/smart_time/parser/smart_date_parser.rb,
lib/smart_time/parser/smart_time_parser.rb

Defined Under Namespace

Modules: ActiveRecordExtension, Parser

Constant Summary collapse

PARSERS_BY_CLASS =
{
	Date => [Parser::SmartDateParser, Parser::RubyDateParser],
	Time => [Parser::SmartTimeParser, Parser::RubyTimeParser]
}

Class Method Summary collapse

Class Method Details

.can_parse?(klass) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/smart_time.rb', line 21

def self.can_parse?(klass)
	PARSERS_BY_CLASS.include?(klass)
end

.parse(value, klass, options) ⇒ Object



25
26
27
28
29
30
# File 'lib/smart_time.rb', line 25

def self.parse(value, klass, options)
	PARSERS_BY_CLASS[klass].each do |parser|
		result = parser.parse(value, options)
		return result if result
	end
end