Class: Dalt::Parser
- Inherits:
-
Object
- Object
- Dalt::Parser
- Defined in:
- lib/dalt/parser.rb
Overview
Parser is used to parse the date and will return alternate text if failed
Instance Attribute Summary collapse
-
#alternate ⇒ Object
Returns the value of attribute alternate.
-
#date ⇒ Object
Returns the value of attribute date.
Instance Method Summary collapse
-
#initialize(date_string, alt: nil) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(date_string, alt: nil) ⇒ Parser
Returns a new instance of Parser.
6 7 8 9 10 |
# File 'lib/dalt/parser.rb', line 6 def initialize(date_string, alt: nil) @date = nil @date_string = date_string @alternate = alt end |
Instance Attribute Details
#alternate ⇒ Object
Returns the value of attribute alternate.
4 5 6 |
# File 'lib/dalt/parser.rb', line 4 def alternate @alternate end |
#date ⇒ Object
Returns the value of attribute date.
4 5 6 |
# File 'lib/dalt/parser.rb', line 4 def date @date end |
Instance Method Details
#parse ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/dalt/parser.rb', line 12 def parse @date = Date.parse(@date_string) rescue StandardError raise ::Dalt::Error::WithoutAlternate if alternate.nil? alternate end |