Class: KDL::Types::Duration
- Defined in:
- lib/kdl/types/duration.rb,
lib/kdl/types/duration/iso8601_parser.rb
Defined Under Namespace
Classes: ISO8601Parser
Constant Summary
Constants inherited from Value
Instance Attribute Summary collapse
-
#days ⇒ Object
readonly
Returns the value of attribute days.
-
#hours ⇒ Object
readonly
Returns the value of attribute hours.
-
#minutes ⇒ Object
readonly
Returns the value of attribute minutes.
-
#months ⇒ Object
readonly
Returns the value of attribute months.
-
#seconds ⇒ Object
readonly
Returns the value of attribute seconds.
-
#weeks ⇒ Object
readonly
Returns the value of attribute weeks.
-
#years ⇒ Object
readonly
Returns the value of attribute years.
Attributes inherited from Value
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(parts = {}, format: nil, type: 'duration') ⇒ Duration
constructor
A new instance of Duration.
Methods inherited from Value
#as_type, from, #stringify_value, #to_s
Constructor Details
#initialize(parts = {}, format: nil, type: 'duration') ⇒ Duration
Returns a new instance of Duration.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/kdl/types/duration.rb', line 8 def initialize(parts = {}, format: nil, type: 'duration') super @years = parts.fetch(:years, 0) @months = parts.fetch(:months, 0) @weeks = parts.fetch(:weeks, 0) @days = parts.fetch(:days, 0) @hours = parts.fetch(:hours, 0) @minutes = parts.fetch(:minutes, 0) @seconds = parts.fetch(:seconds, 0) end |
Instance Attribute Details
#days ⇒ Object (readonly)
Returns the value of attribute days.
6 7 8 |
# File 'lib/kdl/types/duration.rb', line 6 def days @days end |
#hours ⇒ Object (readonly)
Returns the value of attribute hours.
6 7 8 |
# File 'lib/kdl/types/duration.rb', line 6 def hours @hours end |
#minutes ⇒ Object (readonly)
Returns the value of attribute minutes.
6 7 8 |
# File 'lib/kdl/types/duration.rb', line 6 def minutes @minutes end |
#months ⇒ Object (readonly)
Returns the value of attribute months.
6 7 8 |
# File 'lib/kdl/types/duration.rb', line 6 def months @months end |
#seconds ⇒ Object (readonly)
Returns the value of attribute seconds.
6 7 8 |
# File 'lib/kdl/types/duration.rb', line 6 def seconds @seconds end |
#weeks ⇒ Object (readonly)
Returns the value of attribute weeks.
6 7 8 |
# File 'lib/kdl/types/duration.rb', line 6 def weeks @weeks end |
#years ⇒ Object (readonly)
Returns the value of attribute years.
6 7 8 |
# File 'lib/kdl/types/duration.rb', line 6 def years @years end |