Class: KakaxiParse::Datatype::DateTime

Inherits:
Object
  • Object
show all
Defined in:
lib/kakaxi_parse/datatypes/datetime.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ DateTime

Returns a new instance of DateTime.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/kakaxi_parse/datatypes/datetime.rb', line 6

def initialize(*args)
  if args.length == 1 && args[0].class == String
    datetime = DateTime.strptime(args[0], '%Y-%m-%dT%H:%M:%S.%LZ')
    @year = datetime.year
    @month = datetime.month
    @day = datetime.day
    @hour = datetime.hour
    @minute = datetime.minute
    @second = datetime.second
  else
    @year = args[0] || nil
    @month = args[1] || nil
    @day = args[2] || nil
    @hour = args[3] || nil
    @minute = args[4] || nil
    @second = args[5] || nil
  end
end

Instance Attribute Details

#dayObject

Returns the value of attribute day.



4
5
6
# File 'lib/kakaxi_parse/datatypes/datetime.rb', line 4

def day
  @day
end

#hourObject

Returns the value of attribute hour.



4
5
6
# File 'lib/kakaxi_parse/datatypes/datetime.rb', line 4

def hour
  @hour
end

#minuteObject

Returns the value of attribute minute.



4
5
6
# File 'lib/kakaxi_parse/datatypes/datetime.rb', line 4

def minute
  @minute
end

#monthObject

Returns the value of attribute month.



4
5
6
# File 'lib/kakaxi_parse/datatypes/datetime.rb', line 4

def month
  @month
end

#secondObject

Returns the value of attribute second.



4
5
6
# File 'lib/kakaxi_parse/datatypes/datetime.rb', line 4

def second
  @second
end

#yearObject

Returns the value of attribute year.



4
5
6
# File 'lib/kakaxi_parse/datatypes/datetime.rb', line 4

def year
  @year
end