Module: Quando
- Defined in:
- lib/quando.rb,
lib/quando/config.rb,
lib/quando/parser.rb,
lib/quando/version.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
'0.0.6'
Class Method Summary collapse
-
.config ⇒ Quando::Config
Quando’s class-level configuration.
- .configure {|config| ... } ⇒ Quando::Config
- .parse(date, opts = {}) ⇒ Date?
-
.reset! ⇒ Quando::Config
Reset Quando’s class-level configuration to defaults.
Class Method Details
.config ⇒ Quando::Config
Quando’s class-level configuration
94 95 96 |
# File 'lib/quando/config.rb', line 94 def self.config @config ||= Config.new end |
.configure {|config| ... } ⇒ Quando::Config
99 100 101 102 103 |
# File 'lib/quando/config.rb', line 99 def self.configure config unless @config yield(config) if block_given? @config end |
.parse(date, opts = {}) ⇒ Date?
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/quando.rb', line 15 def self.parse(date, opts = {}) return if (date = date.to_s.strip).empty? p = Parser.new if opts[:matcher] p.configure do |c| c.formats = [opts[:matcher]].flatten end end if opts[:century] p.configure do |c| c.century = opts[:century] end end p.parse(date) end |
.reset! ⇒ Quando::Config
Reset Quando’s class-level configuration to defaults
107 108 109 |
# File 'lib/quando/config.rb', line 107 def self.reset! @config = Config.new end |