Class: Datte::Parser
- Inherits:
-
Object
- Object
- Datte::Parser
- Defined in:
- lib/datte/parser.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ locale: 'ja_JP' }
Class Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Parser
constructor
A new instance of Parser.
- #parse_date(body) ⇒ Object
- #to_date ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Parser
Returns a new instance of Parser.
20 21 22 |
# File 'lib/datte/parser.rb', line 20 def initialize( = {}) @options = self.class..merge() end |
Class Attribute Details
.default_options ⇒ Object
15 16 17 |
# File 'lib/datte/parser.rb', line 15 def @default_options ||= DEFAULT_OPTIONS.dup end |
.locale ⇒ Object
10 11 12 |
# File 'lib/datte/parser.rb', line 10 def locale @locale || :ja end |
Instance Method Details
#parse_date(body) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/datte/parser.rb', line 24 def parse_date(body) body = TextConverter.new().kan_num(body) date = DateParser.new(body).parse p date return yield(date) if block_given? && !date.nil? return date end |
#to_date ⇒ Object
32 33 34 |
# File 'lib/datte/parser.rb', line 32 def to_date @date end |