Class: OpenHAB::CoreExt::Java::Period
- Inherits:
- 
      Object
      
        - Object
- OpenHAB::CoreExt::Java::Period
 
- Includes:
- TemporalAmount
- Defined in:
- lib/openhab/core_ext/java/period.rb
Overview
Extensions to java.time.Period
Instance Method Summary collapse
- #<=>(other) ⇒ Integer?
- 
  
    
      #coerce(other)  ⇒ Array? 
    
    
  
  
  
  
  
  
  
  
  
    Convert selfandotherto Duration, ifotheris a Numeric.
- 
  
    
      #to_f  ⇒ Float 
    
    
  
  
  
  
  
  
  
  
  
    Convert to number of seconds. 
- 
  
    
      #to_i  ⇒ Integer 
    
    
  
  
  
  
  
  
  
  
  
    Convert to number of seconds. 
Methods included from TemporalAmount
#-@, #ago, #from_now, #inspect
Instance Method Details
#<=>(other) ⇒ Integer?
| 37 38 39 40 41 | # File 'lib/openhab/core_ext/java/period.rb', line 37 def <=>(other) return to_i <=> other if other.is_a?(Numeric) super end | 
#coerce(other) ⇒ Array?
Convert self and other to Duration, if other is a Numeric
| 49 50 51 | # File 'lib/openhab/core_ext/java/period.rb', line 49 def coerce(other) [other.seconds, to_i.seconds] if other.is_a?(Numeric) end | 
#to_f ⇒ Float
Convert to number of seconds
| 30 31 32 | # File 'lib/openhab/core_ext/java/period.rb', line 30 def to_f to_i.to_f end | 
#to_i ⇒ Integer
Convert to number of seconds
| 17 18 19 20 21 22 23 | # File 'lib/openhab/core_ext/java/period.rb', line 17 def to_i [java.time.temporal.ChronoUnit::YEARS, java.time.temporal.ChronoUnit::MONTHS, java.time.temporal.ChronoUnit::DAYS].sum do |unit| get(unit) * unit.duration.to_i end end | 
 
          