Class: Camdram::TimePeriod

Inherits:
Base
  • Object
show all
Defined in:
lib/camdram/time_period.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#id

Instance Method Summary collapse

Methods inherited from Base

#make_orphan

Constructor Details

#initialize(*args) ⇒ Camdram::TimePeriod

Instantiate a new TimePeriod object from a JSON hash

Parameters:

  • options (Hash)

    A single JSON hash with symbolized keys.


13
14
15
16
17
# File 'lib/camdram/time_period.rb', line 13

def initialize(*args)
  super(*args)
  @start_at = DateTime.parse(@start_at) unless @start_at.nil?
  @end_at = DateTime.parse(@end_at) unless @end_at.nil?
end

Instance Attribute Details

#end_atObject

Returns the value of attribute end_at


7
8
9
# File 'lib/camdram/time_period.rb', line 7

def end_at
  @end_at
end

#full_nameObject

Returns the value of attribute full_name


7
8
9
# File 'lib/camdram/time_period.rb', line 7

def full_name
  @full_name
end

#nameObject

Returns the value of attribute name


7
8
9
# File 'lib/camdram/time_period.rb', line 7

def name
  @name
end

#short_nameObject

Returns the value of attribute short_name


7
8
9
# File 'lib/camdram/time_period.rb', line 7

def short_name
  @short_name
end

#slugObject

Returns the value of attribute slug


7
8
9
# File 'lib/camdram/time_period.rb', line 7

def slug
  @slug
end

#start_atObject

Returns the value of attribute start_at


7
8
9
# File 'lib/camdram/time_period.rb', line 7

def start_at
  @start_at
end

Instance Method Details

#infoHash

Return a hash of the time period's attributes

Returns:

  • (Hash)

    Hash with symbolized keys.


22
23
24
25
26
27
28
29
30
31
# File 'lib/camdram/time_period.rb', line 22

def info
  {
    short_name: short_name,
    name: name,
    full_name: full_name,
    slug: slug,
    start_at: start_at,
    end_at: end_at,
  }
end