Class: Mysql::Time
- Inherits:
- 
      Object
      
        - Object
- Mysql::Time
 
- Defined in:
- lib/ffi-mysql/time.rb
Instance Attribute Summary collapse
- 
  
    
      #day  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute day. 
- 
  
    
      #hour  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute hour. 
- 
  
    
      #minute  ⇒ Object 
    
    
      (also: #min)
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute minute. 
- 
  
    
      #month  ⇒ Object 
    
    
      (also: #mon)
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute month. 
- 
  
    
      #neg  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute neg. 
- 
  
    
      #second  ⇒ Object 
    
    
      (also: #sec)
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute second. 
- 
  
    
      #second_part  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute second_part. 
- 
  
    
      #year  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute year. 
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- 
  
    
      #initialize(year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0, neg = false, second_part = 0)  ⇒ Time 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Time. 
- #to_s ⇒ Object
Constructor Details
#initialize(year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0, neg = false, second_part = 0) ⇒ Time
Returns a new instance of Time.
| 3 4 5 6 | # File 'lib/ffi-mysql/time.rb', line 3 def initialize(year=0, month=0, day=0, hour=0, minute=0, second=0, neg=false, second_part=0) @year, @month, @day, @hour, @minute, @second, @neg, @second_part = year.to_i, month.to_i, day.to_i, hour.to_i, minute.to_i, second.to_i, neg, second_part.to_i end | 
Instance Attribute Details
#day ⇒ Object
Returns the value of attribute day.
| 7 8 9 | # File 'lib/ffi-mysql/time.rb', line 7 def day @day end | 
#hour ⇒ Object
Returns the value of attribute hour.
| 7 8 9 | # File 'lib/ffi-mysql/time.rb', line 7 def hour @hour end | 
#minute ⇒ Object Also known as: min
Returns the value of attribute minute.
| 7 8 9 | # File 'lib/ffi-mysql/time.rb', line 7 def minute @minute end | 
#month ⇒ Object Also known as: mon
Returns the value of attribute month.
| 7 8 9 | # File 'lib/ffi-mysql/time.rb', line 7 def month @month end | 
#neg ⇒ Object
Returns the value of attribute neg.
| 7 8 9 | # File 'lib/ffi-mysql/time.rb', line 7 def neg @neg end | 
#second ⇒ Object Also known as: sec
Returns the value of attribute second.
| 7 8 9 | # File 'lib/ffi-mysql/time.rb', line 7 def second @second end | 
#second_part ⇒ Object
Returns the value of attribute second_part.
| 7 8 9 | # File 'lib/ffi-mysql/time.rb', line 7 def second_part @second_part end | 
#year ⇒ Object
Returns the value of attribute year.
| 7 8 9 | # File 'lib/ffi-mysql/time.rb', line 7 def year @year end | 
Instance Method Details
#==(other) ⇒ Object
| 12 13 14 15 16 17 | # File 'lib/ffi-mysql/time.rb', line 12 def ==(other) other.is_a?(Mysql::Time) && @year == other.year && @month == other.month && @day == other.day && @hour == other.hour && @minute == other.minute && @second == other.second && @neg == neg && @second_part == other.second_part end | 
#eql?(other) ⇒ Boolean
| 19 20 21 | # File 'lib/ffi-mysql/time.rb', line 19 def eql?(other) self == other end | 
#to_s ⇒ Object
| 23 24 25 26 27 28 29 30 | # File 'lib/ffi-mysql/time.rb', line 23 def to_s if year == 0 and mon == 0 and day == 0 h = neg ? hour * -1 : hour sprintf "%02d:%02d:%02d", h, min, sec else sprintf "%04d-%02d-%02d %02d:%02d:%02d", year, mon, day, hour, min, sec end end |