Class: Saxon::ItemType::ValueToRuby::DateTimeConvertor
- Inherits:
-
Object
- Object
- Saxon::ItemType::ValueToRuby::DateTimeConvertor
- Defined in:
- lib/saxon/item_type/value_to_ruby.rb
Instance Attribute Summary collapse
-
#match ⇒ Object
readonly
Returns the value of attribute match.
-
#timestring ⇒ Object
readonly
Returns the value of attribute timestring.
Class Method Summary collapse
Instance Method Summary collapse
- #convert ⇒ Object
- #decimal_part ⇒ Object
-
#initialize(xdm_atomic_value) ⇒ DateTimeConvertor
constructor
A new instance of DateTimeConvertor.
- #integer_parts ⇒ Object
- #tz_part ⇒ Object
Constructor Details
#initialize(xdm_atomic_value) ⇒ DateTimeConvertor
Returns a new instance of DateTimeConvertor.
19 20 21 22 |
# File 'lib/saxon/item_type/value_to_ruby.rb', line 19 def initialize(xdm_atomic_value) @timestring = xdm_atomic_value.to_s @match = ValueToRuby::Patterns::DATE_TIME.match(@timestring) end |
Instance Attribute Details
#match ⇒ Object (readonly)
Returns the value of attribute match.
17 18 19 |
# File 'lib/saxon/item_type/value_to_ruby.rb', line 17 def match @match end |
#timestring ⇒ Object (readonly)
Returns the value of attribute timestring.
17 18 19 |
# File 'lib/saxon/item_type/value_to_ruby.rb', line 17 def timestring @timestring end |
Class Method Details
.call(xdm_atomic_value) ⇒ Object
13 14 15 |
# File 'lib/saxon/item_type/value_to_ruby.rb', line 13 def self.call(xdm_atomic_value) new(xdm_atomic_value).convert end |
Instance Method Details
#convert ⇒ Object
24 25 26 27 |
# File 'lib/saxon/item_type/value_to_ruby.rb', line 24 def convert return timestring if match.nil? Time.new(*integer_parts, decimal_part, tz_part) end |
#decimal_part ⇒ Object
33 34 35 |
# File 'lib/saxon/item_type/value_to_ruby.rb', line 33 def decimal_part Float(match[6]) end |
#integer_parts ⇒ Object
29 30 31 |
# File 'lib/saxon/item_type/value_to_ruby.rb', line 29 def integer_parts match[1..5].map { |n| Integer(n, 10) } end |
#tz_part ⇒ Object
37 38 39 40 |
# File 'lib/saxon/item_type/value_to_ruby.rb', line 37 def tz_part tz_string = match[7] tz_string == 'Z' ? '+00:00' : tz_string end |