Class: Gaah::Calendar::When

Inherits:
Object
  • Object
show all
Defined in:
lib/gaah/calendar/when.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_time, end_time) ⇒ When

Returns a new instance of When.



5
6
7
8
9
10
11
12
13
# File 'lib/gaah/calendar/when.rb', line 5

def initialize(start_time, end_time)
  if start_time.is_a? Hash
    @start_time = Time.parse(start_time.values.first)
    @end_time   = Time.parse(end_time.values.first)
  else
    @start_time = Time.parse(start_time)
    @end_time   = Time.parse(end_time)
  end
end

Instance Attribute Details

#end_timeObject

Returns the value of attribute end_time.



4
5
6
# File 'lib/gaah/calendar/when.rb', line 4

def end_time
  @end_time
end

#start_timeObject

Returns the value of attribute start_time.



4
5
6
# File 'lib/gaah/calendar/when.rb', line 4

def start_time
  @start_time
end

Instance Method Details

#to_json(*args) ⇒ Object



15
16
17
18
19
20
# File 'lib/gaah/calendar/when.rb', line 15

def to_json(*args)
  {
    start_time: @start_time,
    end_time:   @end_time,
  }.to_json
end